Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HUUGE CHANGE: Semicolons are history - or at least completely optiona…
…l now! A newline will do it, except for literal strings, hashes, arrays & blocks, which _can_ have linebreaks in them. Much nicer syntax for Fancy. Yay!
- Loading branch information
Showing
68 changed files
with
1,309 additions
and
1,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
23 + 32432.32 println; | ||
324432.432 - 32432.4324 println; | ||
32432 * 432.32 println; | ||
23 + 32432.32 println | ||
324432.432 - 32432.4324 println | ||
32432 * 432.32 println | ||
432 / 12319 println |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
# some array example code | ||
|
||
# create an array | ||
arr = [1,2,3,4,5,6]; | ||
arr = [1,2,3,4,5,6] | ||
|
||
# print each element squared | ||
arr each: |x| { | ||
x squared println | ||
}; | ||
} | ||
|
||
# display each element with its index in the array | ||
arr each_with_index: |x i| { | ||
"Index " ++ i ++ " -> " ++ x println | ||
}; | ||
} | ||
|
||
# print the array of squared elements | ||
arr map: 'squared . inspect println; | ||
arr map: 'squared . inspect println | ||
|
||
# print the array of doubled elements | ||
arr map: 'doubled . inspect println; | ||
arr map: 'doubled . inspect println | ||
|
||
# print array of all elements smaller than 4 | ||
arr select: |x| { x < 4 } . inspect println; | ||
arr select: |x| { x < 4 } . inspect println | ||
|
||
# print array of all elements that are not smaller than 4 | ||
arr reject: |x| { x < 4 } . inspect println; | ||
arr reject: |x| { x < 4 } . inspect println | ||
|
||
# prints: [5, 6] | ||
arr take_while: |x| { x < 5 } . inspect println; | ||
arr take_while: |x| { x < 5 } . inspect println | ||
|
||
"testing reduce:with: " print; | ||
arr reduce: |acc x| { acc * x } with: 1 . println; # same as: 1*1*2*3*4*5*6 | ||
"testing reduce:with: " print | ||
arr reduce: |acc x| { acc * x } with: 1 . println # same as: 1*1*2*3*4*5*6 | ||
|
||
"testing any?: " print; | ||
arr any?: |x| { x > 3 } . println; # prints: true | ||
"testing any?: " print | ||
arr any?: |x| { x > 3 } . println # prints: true | ||
|
||
"testing all?: " print; | ||
arr all?: |x| { x < 7 } . println; # prints: true | ||
"testing all?: " print | ||
arr all?: |x| { x < 7 } . println # prints: true | ||
|
||
"testing from:to: " print; | ||
arr [[3,5]] . inspect println; # prints: [4, 5, 6] | ||
"testing from:to: " print | ||
arr [[3,5]] . inspect println # prints: [4, 5, 6] | ||
|
||
# some other handy methods | ||
"testing size: " print; | ||
arr size println; # prints: 6 | ||
"testing size: " print | ||
arr size println # prints: 6 | ||
|
||
"testing to_s: " print; | ||
arr to_s println; # prints: 123456 | ||
"testing to_s: " print | ||
arr to_s println # prints: 123456 | ||
|
||
"testing inspect: " print; | ||
"testing inspect: " print | ||
arr inspect println # prints: [1, 2, 3, 4, 5, 6] : Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
x = { Console println: "Println from within block!" }; | ||
x call; # calls x and prints: "Println from within block!" | ||
x = { Console println: "Println from within block!" } | ||
x call # calls x and prints: "Println from within block!" | ||
|
||
y = |x y| { Console println: $ x + y }; | ||
y call: [2, 3]; # calls y and prints: 5 | ||
y = |x y| { Console println: $ x + y } | ||
y call: [2, 3] # calls y and prints: 5 | ||
|
||
# prints numbers 0 to 20 | ||
zahl = 0; | ||
zahl = 0 | ||
{ zahl <= 20 } while_true: { | ||
Console println: zahl; | ||
Console println: zahl | ||
zahl = zahl + 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ def class Number { | |
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
15 times: |x| { | ||
x fib println | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{ | ||
Directory create: "tmp/" | ||
} unless: $ Directory exists?: "tmp/"; | ||
} unless: $ Directory exists?: "tmp/" | ||
|
||
File open: "tmp/Hello-World.txt" modes: ['write] with: |f| { | ||
f write: "Hello, world" . newline | ||
}; | ||
} | ||
|
||
File delete: "tmp/Hello-World.txt"; | ||
File delete: "tmp/Hello-World.txt" | ||
|
||
arr = [1,2,3,4]; | ||
arr = [1,2,3,4] | ||
File open: "tmp/Array-Test.txt" modes: ['write] with: |f| { | ||
arr each: |x| { | ||
f writeln: x | ||
} | ||
}; | ||
} | ||
|
||
File delete: "tmp/Array-Test.txt"; | ||
File delete: "tmp/Array-Test.txt" | ||
|
||
Directory delete: "tmp/" |
Oops, something went wrong.