2.8 In-place operations

All list construction described so far except join is of a copying nature: every construction by the dot or the curly brackets always creates fresh pairs and an old list is untouched. However, there are operations to modify elements or the structure of an existing list in place. These should be used only with greatest care: if there is another reference to the list, its structure will be modified too, a possibly unwanted side effect. The functions are6 :



car l := ureplace first element of l by u
rplaca(l,u)old form for car l := u
cdr l := ureplace cdr part of l by u
rplacd(l,u)old form for cdr l := u
nth(l,j) := ureplace the j-th element of l by u
nconc(a,b)insert b as cdr in the last pair of a
reversip(l)invert the sequence of l using the same pairs again