University of Washington • CSE583 • D. Notkin
©
2000
45
Another functional
l
reduce
: take a binary operator and apply to
pairs of list elements to compute a result
l
(define (sum x)
(reduce + 0 x))
l
(define (prod x) (reduce * 1 x))
l
l
l