type: function (subr) location: built-in source file: xllist.c Common LISP compatible: similar supported on: all machines
(delete-if <test> <list> ) <test> - the test function to be performed <list> - the list to delete from
DELETE-IF destructively modifies the <list> by removing the elements of the <list> that pass the <test>. The destructive aspect of this operation means that the actual symbol value is used in the list-modifying operations - not a copy. <list> must evaluate to a valid list. An atom for <list> will result in an error. Having NIL for <list> will return a NIL as the result.
(setq mylist '(1 2 3 4 5 6 7 8)) ; set up a list (delete-if 'oddp mylist) ; returns (2 4 6 8) (print mylist) ; prints (2 4 6 8) ; note that MYLIST is affected (setq mylist '(a nil b nil c)) ; set up a list (delete-if 'null mylist) ; returns (A B C)
BUG: DELETE-IF will return the proper value, but it does not always properly modify the symbol containing the value. This seems to be true if the first element of the <list> passes the test (and should be deleted).
COMMON LISP COMPATIBILITY: XLISP does not support the :FROM-END, :START, :END, :COUNT and :KEY keywords which Common LISP does.