projects
/
sicp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
48c1360
)
added a church-to-numeral fn and test.
author
Ramakrishnan Muthukrishnan
<vu3rdd@gmail.com>
Sat, 12 Jun 2010 10:54:59 +0000
(16:24 +0530)
committer
Ramakrishnan Muthukrishnan
<vu3rdd@gmail.com>
Sat, 12 Jun 2010 10:54:59 +0000
(16:24 +0530)
src/sicp/ex2_6.clj
patch
|
blob
|
history
diff --git
a/src/sicp/ex2_6.clj
b/src/sicp/ex2_6.clj
index 6101e3907922650aed246060bb72ef2838cb72f9..39fae1eef3a576be52f4bdf888ee83ef80e4feef 100644
(file)
--- a/
src/sicp/ex2_6.clj
+++ b/
src/sicp/ex2_6.clj
@@
-59,4
+59,12
@@
;; 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