Remove
Remove all occurrences
General Forms:
(remove x lst)
(remove x lst :test 'eql) ; same as above (eql as equality test)
(remove x lst :test 'eq) ; same, but eq is equality test
(remove x lst :test 'equal) ; same, but equal is equality test
(Remove x lst) is equal to lst if x is not a member of
lst, else is the result of removing all occurrences of x from
lst. The optional keyword, :TEST, has no effect logically, but
provides the test (default eql) used for comparing x with
successive elements of lst.
Also see remove1.
The guard for a call of remove depends on the test. In all
cases, the second argument must satisfy true-listp. If the test is
eql, then either the first argument must be suitable for eql
(see eqlablep) or the second argument must satisfy eqlable-listp. If the test is eq, then either the first argument
must be a symbol or the second argument must satisfy symbol-listp.
See equality-variants for a discussion of the relation between
remove and its variants:
(remove-eq x lst) is equivalent to (remove x lst :test
'eq);
(remove-equal x lst) is equivalent to (remove x lst :test
'equal).
In particular, reasoning about any of these primitives reduces to reasoning
about the function remove-equal.
Function: remove-equal
(defun remove-equal (x l)
(declare (xargs :guard (true-listp l)))
(cond ((endp l) nil)
((equal x (car l))
(remove-equal x (cdr l)))
(t (cons (car l)
(remove-equal x (cdr l))))))
Remove is defined by Common Lisp. See any Common Lisp documentation
for more information.
Subtopics
- Std/lists/remove
- Lemmas about remove available in the std/lists
library.