Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def first (fn [first]
(fn [second] first)))
(def second (fn [first]
(fn [second] second)))
(def make-pair (fn [first] (fn [second] (fn [func] ((func first) second)))))
(def TRUE first)
(def FALSE second)
(def COND (fn [exp1]
(fn [exp2]
(fn [c]
((c exp1) exp2)))))
(def NOT (fn [c]
(def AND (fn [exp1]
(fn [exp2]
(((COND exp2) FALSE) exp1))))
(def OR (fn [exp1]
(fn [exp2]
(((COND TRUE) exp2) exp1))))
(def zero identity)
(def succ (fn [n]
(fn [s] ((s FALSE) n))))
(def pred (fn [n]
(n second)))
(def iszero (fn [n]
(n first)))
(def pred (fn [n]
(((iszero n) n) (n second))))
(def one (succ zero))
(def two (succ one))
(def three (succ two))
(def two (pred three))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment