]> git.rkrishnan.org Git - sicp.git/commitdiff
solution to 1.41
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 27 May 2010 14:26:12 +0000 (19:56 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Thu, 27 May 2010 14:26:12 +0000 (19:56 +0530)
src/sicp/ex1_41.clj [new file with mode: 0644]

diff --git a/src/sicp/ex1_41.clj b/src/sicp/ex1_41.clj
new file mode 100644 (file)
index 0000000..17bf21c
--- /dev/null
@@ -0,0 +1,22 @@
+(ns sicp.ex1_41
+  (:use [clojure.contrib test-is]
+       [sicp utils]
+       [sicp ch1_3]))
+
+(defn doub [f]
+  (fn [x] (f (f x))))
+
+(comment
+(((doub (doub doub)) inc) 5)
+;;=> 21
+user> ((doub inc) 1)
+;;=> 3
+user> (((doub doub) inc) 1)
+;;=> 5
+user> (((doub (doub doub)) inc) 1)
+;;=> 17
+user> (((doub (doub (doub doub))) inc) 1)
+;;=> 257
+user> (((doub (doub (doub (doub doub)))) inc) 1)
+;;=> 65537
+)
\ No newline at end of file