file: 10-C-lists.muf package: muf status: alpha
The mapcan
function accepts a block of lists and a
function, which must accept as many arguments as there are
lists in the block, and return a list. On the first call to
the given function, it is passed the first element in each
of the given lists. On the second call, it recieves the
second element from each list. This continues until one or
more of the lists run out of elements.
The lists returned from the successive calls are combined
with nconc
and returned as the final result.
Stack: [ [ "a" "b" "c" ]l | :: nil cons ; mapcan --> list Stack: list first list second list third Stack: "a" "b" "c"
The name mapcar
is derived from mapcar
, using
as usual an 'n' to signal a destructive list operation.
Think of mapcan
as providing a way for the fn
to return a variable number of results on each call,
including zero (by returning nil
).
See section mapcar.
Go to the first, previous, next, last section, table of contents.