]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex1_30.clj
Solution to 4.44. A bit too verbose. Can be improved by better
[sicp.git] / src / sicp / ex1_30.clj
1 (ns sicp.ex1_30
2   (:use [sicp utils]
3         [clojure.contrib test-is]))
4
5 (defn sum [term a next b]
6   (letfn [(iter-fn [a result]
7                    (if (> a b)
8                      result
9                      (iter-fn (next a) (+ result (term a)))))]
10     (iter-fn a 0)))