]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex1_30.clj
Solution to 4.33. This had been difficult to get right, though conceptually it was
[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)))