-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlibrary.txt
More file actions
executable file
·57 lines (37 loc) · 889 Bytes
/
library.txt
File metadata and controls
executable file
·57 lines (37 loc) · 889 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
# Combinators
I = \x. x
K = \x y. x
S = \x y z. x z (y z)
Y = \f. (\x. f (x x)) (\x. f (x x))
Om = (\x y. y (x x y)) (\x y. y (x x y))
LOOP = (\x. x x) (\x. x x)
# Logic
T = \x y. x
F = \x y. y
NOT = \p. p F T
AND = \p q. p q F
OR = \p q. p T q
COND = \p x y. p x y
# Pairs
FST = \p. p T
SND = \p. p F
PAIR = \a b f. f a b
, = \a b f. f a b
# Arithmetic
ISZERO = \n. n (\x. F) T
SUCC = \n f x. f (n f x)
PLUS = \m n f x. n f (m f x)
+ = \m n f x. n f (m f x)
MULT = \m n f. m (n f)
* = \m n f. m (n f)
POW = \m n. n m
PRED = \n f x. n (\g h. h (g f)) (\u. x) I
TETR = \m n. n (\g. g m) I
FACT = Y (\f n. (ISZERO n) 1 (MULT (f (PRED n)) n))
# Lists
NIL = \z. z
CONS = \x y. , F (, x y)
: = \x y. , F (, x y)
NULL = \z. z T
HEAD = \z. FST (SND z)
TAIL = \z. SND (SND z)