From 1e7207dd5f93dfee0437dd6d4e8ec881d6895b37 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Sat, 12 Jun 2010 16:24:59 +0530 Subject: [PATCH] added a church-to-numeral fn and test. --- src/sicp/ex2_6.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sicp/ex2_6.clj b/src/sicp/ex2_6.clj index 6101e39..39fae1e 100644 --- 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: ;; -;; 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 -- 2.45.2