]> git.rkrishnan.org Git - sicp.git/commitdiff
added a church-to-numeral fn and test.
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Sat, 12 Jun 2010 10:54:59 +0000 (16:24 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Sat, 12 Jun 2010 10:54:59 +0000 (16:24 +0530)
src/sicp/ex2_6.clj

index 6101e3907922650aed246060bb72ef2838cb72f9..39fae1eef3a576be52f4bdf888ee83ef80e4feef 100644 (file)
 ;; I used the wikipedia article to study Church Numerals:
 ;; <http://en.wikipedia.org/wiki/Church_encoding#Computation_with_Church_numerals>
 
-;; comments?
\ No newline at end of file
+;; comments?
+
+(defn church-to-numeral [chfn]
+  ((chfn inc) 0))
+
+(deftest test-church-to-numeral
+  (are [x y] [= x y]
+       (church-to-numeral one) 1
+       (church-to-numeral two) 2))
\ No newline at end of file