Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Documentation/Wren/documentation.wren
Normal file
27
Task/Documentation/Wren/documentation.wren
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// The meaning of life!
|
||||
var mol = 42
|
||||
|
||||
// A function to add two numbers
|
||||
var add = Fn.new { |x, y| x + y }
|
||||
|
||||
/* A class with some string utilites */
|
||||
class StrUtil {
|
||||
// reverses an ASCII string
|
||||
static reverse(s) { s[-1..0] }
|
||||
|
||||
// capitalizes the first letter of an ASCII string
|
||||
static capitalize(s) {
|
||||
var firstByte = s[0].bytes[0]
|
||||
if (firstByte >= 97 && firstByte <= 122) {
|
||||
firstByte = firstByte - 32
|
||||
return String.fromByte(firstByte) + s[1..-1]
|
||||
}
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
// test code
|
||||
var smol = "meaning of life"
|
||||
System.print("'%(smol)' + 123 = %(add.call(mol, 123))")
|
||||
System.print("'%(smol)' reversed = %(StrUtil.reverse(smol))")
|
||||
System.print("'%(smol)' capitalized = %(StrUtil.capitalize(smol))")
|
||||
Loading…
Add table
Add a link
Reference in a new issue