Blame


1 665c255d 2023-08-04 jrmu (defun accumulator (combiner null-value term a next b)
2 665c255d 2023-08-04 jrmu (if (> a b)
3 665c255d 2023-08-04 jrmu null-value
4 665c255d 2023-08-04 jrmu (funcall combiner
5 665c255d 2023-08-04 jrmu (funcall term a)
6 665c255d 2023-08-04 jrmu (accumulator combiner null-value term (funcall next a) next b))))
7 665c255d 2023-08-04 jrmu (defun sum (term a next b)
8 665c255d 2023-08-04 jrmu (accumulator #'+ 0 term a next b))
9 665c255d 2023-08-04 jrmu (defun accumulator-iter (combiner null-value term a next b)
10 665c255d 2023-08-04 jrmu (defun iter (a result)
11 665c255d 2023-08-04 jrmu (if (> a b)
12 665c255d 2023-08-04 jrmu result
13 665c255d 2023-08-04 jrmu (iter (funcall next a)
14 665c255d 2023-08-04 jrmu (funcall combiner (funcall term a) result))))