In the structure and interpretation of computer programs (SICP) Section 2.2.3, several functions are defined using:
(accumulate cons nil
(filter pred
(map op sequence)))
Two examples that use this work on a list of fibonacci numbers, even-fibsand list-fib-squares.
The accumulation, filtering and display functions are also defined in section 2.2. The part that bothers me is why the authors included here accumulate. accumulateaccepts 3 parameters:
An example of applying savings to a list using a definition in a book:
(accumulate cons nil (list 1 2 3))
=> (cons 1 (cons 2 (cons 3 nil)))
=> (1 2 3)
, (accumulate cons nil some-list) some-list, (filter pred (map op sequence)) .
accumulate, ?