-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.txt
71 lines (57 loc) · 899 Bytes
/
test.txt
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
print "two";
print false;
print 10 + 30;
var x = 100;
var y = 3;
print x * y;
var a = "global a";
var b = "global b";
var c = "global c";
{
var a = "outer a";
var b = "outer b";
{
var a = "inner a";
print a;
print b;
print c;
}
print a;
print b;
print c;
}
print a;
print b;
print c;
var c = 0;
var d = 1;
while (c < 10000) {
print c;
var temp = c;
c = d;
d = temp + d;
}
fun sayHello(first, last) {
print "Hello, " + first + " " + last + "!";
}
sayHello("Dear", "Reader");
fun fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 2) + fibonacci(n - 1);
}
for (var i = 0; i < 20; i = i + 1) {
print fibonacci(i);
}
print "break";
print "start makeCounter function";
fun makeCounter() {
var i = 0;
fun count() {
i = i + 1;
print i;
}
return count;
}
var counter = makeCounter();
counter(); // "1".
counter(); // "2".