Next: List Searching, Previous: Append/Reverse, Up: Lists
The following procedures modify an existing list, either by changing elements of the list, or by changing the list structure itself.
Set the kth element of list to val.
Set the kth cdr of list to val.
Return a newly-created copy of lst with elements
eq?
to item removed. This procedure mirrorsmemq
:delq
compares elements of lst against item witheq?
.
Return a newly-created copy of lst with elements
eqv?
to item removed. This procedure mirrorsmemv
:delv
compares elements of lst against item witheqv?
.
Return a newly-created copy of lst with elements
equal?
to item removed. This procedure mirrorsmember
:delete
compares elements of lst against item withequal?
.
These procedures are destructive versions of
delq
,delv
anddelete
: they modify the pointers in the existing lst rather than creating a new list. Caveat evaluator: Like other destructive list functions, these functions cannot modify the binding of lst, and so cannot be used to delete the first element of lst destructively.
Like
delq!
, but only deletes the first occurrence of item from lst. Tests for equality usingeq?
. See alsodelv1!
anddelete1!
.
Like
delv!
, but only deletes the first occurrence of item from lst. Tests for equality usingeqv?
. See alsodelq1!
anddelete1!
.
Like
delete!
, but only deletes the first occurrence of item from lst. Tests for equality usingequal?
. See alsodelq1!
anddelv1!
.
Return a list containing all elements from lst which satisfy the predicate pred. The elements in the result list have the same order as in lst. The order in which pred is applied to the list elements is not specified.
filter
does not change lst, but the result may share a tail with it.filter!
may modify lst to construct its return.