Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In SICP 2nd Edition section 2.2.3, the authors have the following code:

(define (even-fibs n)
  (accumulate cons
              (filter even?
                      (map fib
                           (enumerate-interval 0 n)))))

My question is why did they use accumulate in this case? Couldn't they have got the same answer from filter without using accumulate?

share|improve this question
up vote 10 down vote accepted

In that section of the book, filter, map, and enumerate-interval are presumed to return sequences, which are conceptually distinct from lists. You can implement sequences using streams, for example, though you can implement sequences using lists too.

So, in this case, the accumulate with cons is to convert the sequence to a list.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.