The 'delete' function destructively modifies the 'list' by removing the 'expr'. The destructive aspect of this operation means that the actual symbol value is used in the list-modifying operations, not a copy. If 'expr' appears multiple times in the 'list', all occurances will be removed.
'list' must evaluate to a valid list. An atom for 'list' will result in an error:
error: bad argument type
Having NIL for 'list' will return a NIL as the result. You may specify your own test with the ':test' and ':test-not' keywords.
(delete 'b NIL) ; returns NIL (delete 'b '(a b b c b)) ; returns (A C) (setq a '(1 2 3)) (setq b a) ; set up A and B (delete '2 a) ; returns (1 3) (print a) ; prints (1 3) A IS MODIFIED! (print b) ; prints (1 3) B IS MODIFIED! (delete '(b) '((a)(b)(c))) ; returns ((A) (B) (C)) ; EQL doesn't work on lists (delete '(b) '((a)(b)(c)) :test 'equal) ; returns ((A) (C))
Note: The 'delete' function can work with a list or string as the 'expr'. However, the default eql test does not work with lists or strings, only symbols and numbers. To make this work, you need to use the ':test' keyword along with equal for 'test'.
Common Lisp: XLISP does not support the ':from-end', ':start', ':end', ':count' and ':key' keywords which Common Lisp does.
See the
delete
function in the