-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lox
44 lines (38 loc) · 779 Bytes
/
test.lox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This program uses a while loop to count down from 6 to 1, printing each number
// and then decrementing the count until it reaches 0, at which point it prints
// "Blast off!"
// var count = 6;
//
// fun tick() {
// if (count > 0) {
// print count;
// count = count - 1;
// return false;
// }
// print "Blast off!";
// return true;
// }
while (!tick()) {}
// fun returnArg(arg) {
// return arg;
// }
//
// fun returnFunCallWithArg(func, arg) {
// return returnArg(func)(arg);
// }
//
// fun printArg(arg) {
// print arg;
// }
//
// returnArg(printArg)("bar");
fun returnArg(arg) {
return arg;
}
fun returnFunCallWithArg(func, arg) {
return returnArg(func)(arg);
}
fun printArg(arg) {
print arg;
}
returnFunCallWithArg(printArg, "bar");