[archives] [homepage]

Problem 1.30
Friday, August 23, 2019; ago; Download .md

SICP Exercise 1.30

The sum procedure is given as:

(define (sum term a next b)
  (if (> ab)
      (+ (term a)
         (sum term (next a) next b))))

It can be changed to act iteratively as:

(define (sum term a next b)
  (define (iter a result)
    (if (> a b)
        (iter (next a) (+ result (term a)))))
  (iter a 0))