next up previous
Contents Next: apply (FUNCTION) Up: Appendix: Selected LISP Previous: and (MACRO)

append (FUNCTION)

Format: (append <list1> <list2>...<listN> <exp>)

Required arguments: none

Optional arguments: zero or more LISP expressions

<list>: any LISP expression which returns a list; except the last argument may be any LISP expression.

Each of the arguments is evaluated; all except the last must return a list. If all the arguments evaluate to lists, append creates a new list which has as its elements the elements of all the argument lists. If the last argument is not a list, append returns a dotted pair object.

Examples:

> (append '(a b) '(c d))
(A B C D)

> (append '(1 (2 (3))) (i (j) k))
(1 (2 (3)) I (J) K)

> (setq tmp '(fee fi fo))
(FEE FI FO)

> (append tmp (list 'fum))
(FEE FI FO FUM)

> (append '(fo) 'fum)
(FO . FUM)                           ;; this is a dotted pair

> (append 'a '(1 2))
Error: A is not of type LIST



© Colin Allen & Maneesh Dhagat
November 1999