From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 14:26:26 +0000 (+0530) Subject: solution to 1.43 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/%22doc.html/install.html?a=commitdiff_plain;h=472b9ae97eb24f401629249a5c3251c4cc1c82b4;p=sicp.git solution to 1.43 --- diff --git a/src/sicp/ex1_43.clj b/src/sicp/ex1_43.clj new file mode 100644 index 0000000..f7cb7ff --- /dev/null +++ b/src/sicp/ex1_43.clj @@ -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))) +