Scieneer Common Lisp 1.3.9 online documentation

ext:collect collections &body body[Macro]

Collect ({(Name [Initial-Value] [Function])}*) {Form}*

Collect some values somehow. Each of the collections specifies a bunch of things which collected during the evaluation of the body of the form. The name of the collection is used to define a local macro, a la macrolet. Within the body, this macro will evaluate each of its arguments and collect the result, returning the current value after the collection is done. The body is evaluated as a progn; to get the final values when you are done, just call the collection macro with no arguments.

The initial-value is the value that the collection starts out with, which defaults to nil. The function is the function which does the collection. It is a function which will accept two arguments: the value to be collected and the current collection. The result of the function is made the new value for the collection. As a totally magical special-case, the function may be collect, which tells us to build a list in forward order; this is the default. If an initial-value is supplied for collect, the stuff will be rplacd'd onto the end. Note that function may be anything that can appear in the functional position, including macros and lambdas.