2013-03-15 02:03:33 +01:00
|
|
|
#!/usr/bin/env hy
|
|
|
|
|
2013-03-10 00:43:26 +01:00
|
|
|
; Very much a knockoff (straight port) of Dan Gulotta's 2013 MIT Mystery Hunt
|
2013-03-15 02:03:33 +01:00
|
|
|
; puzzle "The Halting Problem". His Copyright terms are unclear, so presume
|
|
|
|
; that this is distributable, but not free.
|
2013-03-10 00:43:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
(defn evaluate [f] ((f (lambda [x] (+ x 1))) 0))
|
|
|
|
|
|
|
|
(defn successor [n] (lambda [f] (lambda [x] (f ((n f) x)))))
|
|
|
|
(defn plus [m n] ((n successor) m))
|
|
|
|
(defn exponent [m n] (n m))
|
|
|
|
(defn zero [f] (lambda [x] x))
|
|
|
|
(defn one [f] (lambda [x] (f x)))
|
|
|
|
|
|
|
|
(defn predecessor [n] (lambda [f] (lambda [x]
|
|
|
|
(((n (lambda [g] (lambda [h] (h (g f))))) (lambda [y] x)) (lambda [z] z)))))
|
|
|
|
|
|
|
|
(defn subtract [m n] ((m predecessor) n))
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv two (plus one one))
|
|
|
|
(setv three (plus two one))
|
2013-03-10 00:43:26 +01:00
|
|
|
|
|
|
|
(print (evaluate (exponent three three)))
|