]> git.rkrishnan.org Git - sicp.git/commitdiff
solution to 1.30
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Tue, 4 May 2010 14:47:28 +0000 (20:17 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Tue, 4 May 2010 14:47:28 +0000 (20:17 +0530)
src/sicp/ex1_30.clj [new file with mode: 0644]

diff --git a/src/sicp/ex1_30.clj b/src/sicp/ex1_30.clj
new file mode 100644 (file)
index 0000000..e447a0a
--- /dev/null
@@ -0,0 +1,10 @@
+(ns sicp.ex1_30
+  (:use [sicp utils]
+       [clojure.contrib test-is]))
+
+(defn sum [term a next b]
+  (letfn [(iter-fn [a result]
+                  (if (> a b)
+                    result
+                    (iter-fn (next a) (+ result (term a)))))]
+    (iter-fn a 0)))
\ No newline at end of file