From: Bruno Haible
Subject: Re: dolist vs mapc; length+last ?
Date: 
Message-ID: <5ukafa$eqi$1@nz12.rz.uni-karlsruhe.de>
Barry Margolin <······@bbnplanet.com> wrote:

> The MAPxxx functions are generally preferable when the function already
> exists.  Note also that many compilers will recognize (mapXXX #'(lambda
> ...) ...)  and open-code it as a loop rather than calling the mapping
> function and generating function calls.

That's exactly what CLISP does. To see how other Lisp implementations treat
this issue, try comparing the output of something like

  (disassemble (lambda (x y) (dolist (i x) (incf y i)) y))
  (disassemble (lambda (x y) (mapc (lambda (i) (incf y i)) x) y))

>> 1. dolist vs. mapc: which to use?

It's a matter of style (aesthetics) and habits. If you are thinking about
an iteration as "ok, here is my list, now what do I do with it", then you
will prefer `dolist'. If, your mental model is "let's build a pipeline,
first the pipeline's engine, then its input", then you will prefer `mapc'.

                    Bruno