-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglambda.go
More file actions
61 lines (43 loc) · 750 Bytes
/
glambda.go
File metadata and controls
61 lines (43 loc) · 750 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
57
58
59
60
61
/*
variables: x, y, z...
functions: λ x • x + 1
application: (λ x • x + 1) 2
= 2 + 1
= 3
multi variable functions:
\ x . \ y . x + y
\ x y . x + y
integers:
0 = \ f x . x
1 = \ f x . f x
2 = \ f x . f (f x)
3 = \ f x . f (f (f x))
...
n = \ f x . f^n x
integer ops:
succ = \ n f x . f (n f x)
add = \ n m f x . n f (m f x)
add = \ n m f x . n succ m
bools:
true = \ x y . x
false = \ x y . y
boolean ops:
not = \ x . x false true
and = \ x y . x y false
or = \ x y . x true y
*/
package glambda
import (
"fmt"
)
func Run() {
code := `
-- this is a comment
test = \ a b . a b
test2 = \ x y . x (y y)
`
nodes := parse(code)
for _, node := range nodes {
fmt.Printf("%s\n", node)
}
}