mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
While is working but untested, read more
* TODO: break and continue keywords need to be implemented * TODO: while-then needs testing * Fixed the parser not liking zero-length strings
This commit is contained in:
27
scripts/fizzbuzz.toy
Normal file
27
scripts/fizzbuzz.toy
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
//moment of truth
|
||||
var counter: int = 1;
|
||||
|
||||
while (counter <= 100) {
|
||||
var result: string = "";
|
||||
|
||||
if (counter % 3 == 0) {
|
||||
result = result .. "fizz";
|
||||
}
|
||||
|
||||
if (counter % 5 == 0) {
|
||||
result = result .. "buzz";
|
||||
}
|
||||
|
||||
//finally
|
||||
if (result == "") {
|
||||
print counter;
|
||||
}
|
||||
else {
|
||||
print result;
|
||||
}
|
||||
|
||||
counter += 1;
|
||||
}
|
||||
|
||||
9
scripts/looping.toy
Normal file
9
scripts/looping.toy
Normal file
@@ -0,0 +1,9 @@
|
||||
var a: int = 0;
|
||||
|
||||
while(a < 10) {
|
||||
print a;
|
||||
a += 1;
|
||||
}
|
||||
|
||||
print "Finished";
|
||||
|
||||
Reference in New Issue
Block a user