mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 06:44:07 +10:00
This required a massive cross-cutting rework to the scope system, multiple subtle bugfixes and relearning of the parser internals, but it does appear that functions are working correctly. A few caveats: for now, parameters are always constant, regardless of type, return values can't be specified, and some script tests have been written. Most importantly, a key feature is working: closures.
10 lines
205 B
Plaintext
10 lines
205 B
Plaintext
//find the leap years
|
|
fn isLeapYear(n: int) {
|
|
if (n % 400 == 0) return true;
|
|
if (n % 100 == 0) return false;
|
|
return n % 4 == 0;
|
|
}
|
|
print isLeapYear(1999);
|
|
print isLeapYear(2000);
|
|
print isLeapYear(2004);
|