Next: List Modification, Previous: List Selection, Up: Lists
append and append! are used to concatenate two or more
lists in order to form a new list. reverse and reverse!
return lists with the same elements as their arguments, but in reverse
order. The procedure variants with an ! directly modify the
pairs which form the list, whereas the other procedures create new
pairs. This is why you should be careful when using the side-effecting
variants.
Return a list comprising all the elements of lists lst1 to lstN.
(append '(x) '(y)) => (x y) (append '(a) '(b c d)) => (a b c d) (append '(a (b)) '((c))) => (a (b) (c))The last argument lstN may actually be any object; an improper list results if the last argument is not a proper list.
(append '(a b) '(c . d)) => (a b c . d) (append '() 'a) => a
appenddoesn't modify the given lists, but the return may share structure with the final lstN.append!modifies the given lists to form its return.For
scm_appendandscm_append_x, lstlst is a list of the list operands lst1 ... lstN. That lstlst itself is not modified or used in the return.
Return a list comprising the elements of lst, in reverse order.
reverseconstructs a new list,reverse!modifies lst in constructing its return.For
reverse!, the optional newtail is appended to to the result. newtail isn't reversed, it simply becomes the list tail. Forscm_reverse_x, the newtail parameter is mandatory, but can beSCM_EOLif no further tail is required.