| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- make "f [[x] [
- make "g [[y] [return add :x :y]]
- return g 42
- ]]
- print f 233
- make "f1 [[x] [
- make "g1 [[y] [return add :x :y]]
- return :g1
- ]
- ]
- make "c1 f1 42
- make "c2 f1 24
- print c1 1
- print c2 2
- make "curry_two [[f x] [
- return [[y] [return f :x :y]]
- ]]
- make "f2 [[x y] [
- return add :x :y
- ]]
- make "f2p curry_two :f2 42
- print f2p 233
- make "fact_base [
- [rec x]
- [
- if eq :x 0
- [return 1]
- [return mul :x rec :rec sub :x 1]
- ]
- ]
- make "fact_simple [
- [x]
- [return fact_base :fact_base :x]
- ]
- print fact_simple 5
- make "fact_nice [
- [rec]
- [
- make "g [
- [x]
- [
- if eq :x 0
- [return 1]
- [
- make "tmp rec :rec
- return mul :x tmp sub :x 1
- ]
- ]
- ]
- return :g
- ]
- ]
- make "fact_curry fact_nice :fact_nice
- print fact_curry 5
- make "fact_nicer [
- [rec]
- [
- make "g [
- [x]
- [
- if eq :x 0
- [return 1]
- [return mul :x rec sub :x 1]
- ]
- ]
- return :g
- ]
- ]
- make "z_comb [
- [g]
- [
- make "t [
- [r]
- [
- make "y [
- [yy]
- [
- make "tmp r :r
- return tmp :yy
- ]
- ]
- return g :y
- ]
- ]
- return t :t
- ]
- ]
- make "fact_z z_comb :fact_nicer
- print fact_z 5
- make "logic_test [[b] [return b 1 0]]
- make "F_TRUE [[x y] [return :x]]
- make "F_FALSE [[x y] [return :y]]
- make "F_AND [[p q] [return p :q :p]]
- make "F_OR [[p q] [return p :p :q]]
- make "F_NOT [[p] [return p :F_FALSE :F_TRUE]]
- print logic_test F_AND F_AND :F_TRUE :F_TRUE :F_FALSE
- print logic_test F_AND F_OR :F_TRUE :F_FALSE :F_FALSE
- print logic_test F_NOT F_AND :F_TRUE :F_FALSE :F_TRUE
- print logic_test F_OR F_NOT :F_TRUE F_NOT :F_FALSE :F_TRUE
- make "church_test [
- [n]
- [
- make "inc [[x] [return add :x 1]]
- return n :inc 0
- ]
- ]
- make "O [
- [f x]
- [return :x]
- ]
- make "succ [
- [n]
- [
- make "t [
- [f x]
- [
- make "tt n :f :x
- return f :tt
- ]
- ]
- return :t
- ]
- ]
- print church_test succ :O
- print church_test succ succ :O
- print church_test succ succ succ :O
|