From 472b9ae97eb24f401629249a5c3251c4cc1c82b4 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 19:56:26 +0530 Subject: [PATCH] solution to 1.43 --- src/sicp/ex1_43.clj | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/sicp/ex1_43.clj 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))) + -- 2.45.2