Common Lisp the Language
2nd Edition

These functions create and process gatherers.
[Function]
gatherer collector
The collector must be a function of type
(function ((series
))
). Given this function
gatherer
returns a gatherer that accepts elements of type
and returns a final
result of type
. The method for combining elements used by the
gatherer is the same as the one used by the collector.
[Function]
next-out gatherer item
Given a gatherer and a value next-out enters the value into the gatherer.
[Function]
result-of gatherer
result-of retrieves the net result from a gatherer. result-of can be applied at any time. However it is an error to apply result-of twice to the same gatherer or to apply next-out to a gatherer once result-of has been applied.
(let ((g (gatherer #'collect-sum))) (dolist (i '(1 2 3 4)) (next-out g i) (if (evenp i) (next-out g (* 10 i)))) (result-of g)) => 70
[Macro]
gathering ({(var fn)}*) {form}*
The first subform must be a list of pairs. The first element of each pair var must be a variable name. The second element of each pair fn fnd element of each pairfn)}*) {form}*
The first subform must be a list of pairs. The first by the finalml