Next: count - counting, Previous: collect - collecting, Up: Value Accumulation [Contents][Index]
append expr [into var] appending expr [into var] nconc expr [into var] nconcing expr [into var]
These constructs are similar to ‘collect’ except that the values of the specified expression must be lists.
keyword causes its list values to be concatenated into a single list, as if
they were arguments to the Common Lisp function append
.
keyword causes its list values to be concatenated into a single list, as if
they were arguments to the Common Lisp function nconc
. Note that the
‘nconc’ keyword destructively modifies its argument lists.
var
is set to the list of concatenated values; if you specify var
, the loop
does not return the final list automatically. The var
argument is bound as
if by the construct ‘with’. You cannot specify a data type for var
; it
must be of type ‘list’.
;;; Use APPEND to concatenate some sublists. (loop for x in '((a) (b) ((c))) append x)
;;; NCONC some sublists together. Note that only lists ;;; made by the call to LIST are modified. (loop for i upfrom 0 as x in '(a b (c)) nconc (if (evenp i) (list x) '()))