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

diff --git a/src/sicp/ex1_43.clj b/src/sicp/ex1_43.clj
new file mode 100644 (file)
index 0000000..f7cb7ff
--- /dev/null
@@ -0,0 +1,14 @@
+(ns sicp.ex1_43
+  (:use [clojure.contrib test-is]
+       [sicp utils]
+       [sicp ch1_3]
+       [sicp ex1_42]))
+
+(defn repeated-1 [f1 f2 m]
+  (cond (= m 0) f1
+       (= m 1) f2
+       :else (repeated-1 f1 (compose f2 f1) (- m 1))))
+
+(defn repeated [f n]
+  (repeated-1 f (compose f f) (- n 1)))
+