Blob


1 (defun accumulator (combiner null-value term a next b)
2 (if (> a b)
3 null-value
4 (funcall combiner
5 (funcall term a)
6 (accumulator combiner null-value term (funcall next a) next b))))
7 (defun sum (term a next b)
8 (accumulator #'+ 0 term a next b))
9 (defun accumulator-iter (combiner null-value term a next b)
10 (defun iter (a result)
11 (if (> a b)
12 result
13 (iter (funcall next a)
14 (funcall combiner (funcall term a) result))))
15 (iter a null-value))
16 (defun product (term a next b)
17 (accumulator-iter #'* 1 term a next b))