Skip to content

Instantly share code, notes, and snippets.

@dsabanin
Created July 15, 2013 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsabanin/6000742 to your computer and use it in GitHub Desktop.
Save dsabanin/6000742 to your computer and use it in GitHub Desktop.
(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]
(((COND FALSE) TRUE) 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