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.


>  (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))

>  (append tmp (list '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
March 2007