-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombinators.mlt
64 lines (56 loc) · 1.54 KB
/
combinators.mlt
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
# joy's names for the builtin mlatu combinators
zap = -.
dup = +.
unit = >.
i = <.
cat = ,.
# swap is already called swap
swapd = (~)dip.
dupd = (+)dip.
over = dupd~.
oover = (over)dip~.
rot = swapd~.
2rot = rot rot.
# some more joy combinators
dip = ~>,<.
cons = (>)dip,.
sip = keep.
dig1 = unit dip. # == swap
dig2 = unit cons dip. # == rot
dig3 = unit cons cons dip.
dig4 = unit cons cons cons dip.
dig5 = unit cons cons cons cons dip.
bury1 = (unit) dip swap i. # == swap
bury2 = (unit cons) dip swap i. # == 2rot
bury3 = (unit cons cons) dip swap i.
bury4 = (unit cons cons cons) dip swap i.
bury5 = (unit cons cons cons cons) dip swap i.
take = ~>,.
flip2 = unit dip.
flip3 = unit take dip.
flip4 = unit take take dip.
flip5 = unit take take take dip.
dip0 = (()) dip dip i.
dip1 = (unit) dip dip i.
dip2 = (unit cons) dip dip i.
dip3 = (unit cons cons) dip dip i.
dip4 = (unit cons cons cons) dip dip i.
dip5 = (unit cons cons cons cons) dip dip i.
swat = swap cat.
sip0 = i. # i couldn't get any of the sipn definitions to work for 0 nicely
sip1 = (unit) dip (i) swat sip i.
sip2 = (unit cons) dip (i) swat sip i.
sip3 = (unit cons cons) dip (i) swat sip i.
sip4 = (unit cons cons cons) dip (i) swat sip i.
sip5 = (unit cons cons cons cons) dip (i) swat sip i.
# factor combinators
# (a) (b) (f) (g) bi* = (a) f (b) g
bi* = (dip)dip<.
# (a) (b) (f) bi* = (a) f (b) f
bi@ = +bi*.
# (a) (f) (g) bi |-> (a) f (a) g
bi = (+)dip2 bi*.
# (a) (f) keep |-> (a) f (a)
keep = over(<)dip.
# (a) (f) keep* |-> (a) f (f)
keep* = +(<)dip.