From: Ramakrishnan Muthukrishnan Date: Sat, 12 Jun 2010 10:54:59 +0000 (+0530) Subject: added a church-to-numeral fn and test. X-Git-Url: https://git.rkrishnan.org/frontends/listings/pb2server.py?a=commitdiff_plain;h=1e7207dd5f93dfee0437dd6d4e8ec881d6895b37;p=sicp.git added a church-to-numeral fn and test. --- 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