-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.lang
More file actions
56 lines (40 loc) · 735 Bytes
/
example.lang
File metadata and controls
56 lines (40 loc) · 735 Bytes
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
let foo = 1
let bar = 2
let list = if(eq(foo, bar), {
print(("true", foo))
[1, 2]
}, {
print(("false", bar))
[3, 4]
})
print(("list", list))
let index = 0
while(lt(index, 10), { # comment
print(index)
index = add(index, 1)
})
print(("final i", index))
let add_two = fn(x: int) {
add(x, 2)
}
# other
print(("add_two", add_two(4)))
let const = 4
let outer = fn (x: int, y: int) {
let inner = fn (a: int, b: int) {
add(add(a, b), const)
}
add(x, inner(y, 5))
}
print(("outer", outer(10, 20)))
const = 5
print(("outer", outer(10, 20)))
let lambda = fn () {
let closed = 4
fn () {
closed
}
}
let lambda_inner = lambda()
print(("closed", lambda_inner()))
1