Fixed invoking functions within function arguments
Somewhat similar to c9d4b9965c
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//WARN: This is just a scratch pad, don't use it
|
||||
|
||||
//for (var i in array) print i;
|
||||
//for (var i in range(10)) print i;
|
||||
|
||||
|
||||
//example of a `range` function
|
||||
fn range(limit: Int) {
|
||||
var counter: Int = 0;
|
||||
|
||||
fn next() {
|
||||
if (counter >= limit) {
|
||||
return null;
|
||||
}
|
||||
else return counter++;
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
var next = range(10);
|
||||
|
||||
|
||||
fn log(x) {
|
||||
if (x == null) return;
|
||||
print x;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
log(next());
|
||||
}
|
||||
Reference in New Issue
Block a user