XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

nconc


Type:   -   function (subr)
Source:   -   xllist.c

Syntax

(nconc [list1 ... ])
listN - a list to destructively concatenate
returns - the result of concatenating the lists

Description

The 'nconc' function destructively concatenates a sequence of lists and returns the result of this concatentation. The destructive aspect of this operation means that the actual symbol values are used in the list-modifying operations, not copies. This means, for 'nconc', that the lists are spliced together. 'listN' must evaluate to a valid list. An atom for 'listN' will result in an error. NIL is a valid 'listN'.

Examples

(setq a '(1 2 3))      ; set up A with (1 2 3)
(setq b '(4 5 6))      ; set up B with (4 5 6)
(setq c '(7 8 9))      ; set up C with (7 8 9)
(NCONC a b c)          ; returns (1 2 3 4 5 6 7 8 9)
(setf (nth 8 a) 'end)  ; change last element of A
(print a)              ; prints (1 2 3 4 5 6 7 8 END)
(print b)              ; prints (4 5 6 7 8 END)
(print c)              ; prints (7 8 END)

Note: with Nyquist, no error is raised if 'listN' is an atom. Instead, all atoms given to the 'nconc' function, if not given as the last argument, just disappear:

(nconc 'a 'b 'c 'd)       ; returns D
(nconc 'a '(b) 'c '(d))   ; returns (B D)
(nconc '(a) 'b '(c) 'd)   ; returns (A C . D)

See the nconc function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next