done with 11

This commit is contained in:
2018-07-25 15:32:37 +02:00
parent 13106d1788
commit 5adcf93d74
12 changed files with 252 additions and 53 deletions

10
examples/counter.lox Normal file
View File

@@ -0,0 +1,10 @@
fn makeCounter() {
let i = 0;
fn count() {
i = i + 1;
}
}
let counter = makeCounter();
print(counter()); // "1".
print(counter()); // "2".

8
examples/fib.lox Normal file
View File

@@ -0,0 +1,8 @@
fn fibonacci(n) {
if n <= 1 { return n; }
return fibonacci(n - 2) + fibonacci(n - 1);
}
for let i = 0; i < 25; i = i + 1 {
print(fibonacci(i));
}

9
examples/thrice.lox Normal file
View File

@@ -0,0 +1,9 @@
fn thrice(f) {
for let i = 1; i <= 3; i = i + 1 {
f(i);
}
}
thrice(fn (a) {
print(a);
});