Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

delete

delete

type: function (subr) 
location: built-in
source file: xllist.c
Common LISP compatible: similar
supported on: all machines

SYNTAX

(delete <expr>   [ { :test | :test-not }  ] )
        <expr>          -       the expression to delete from <list>
        <list>          -       the list to DESTRUCTIVELY modify
        <test>          -       optional test function (default is EQL)

DESCRIPTION

DELETE 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. Having NIL for <list> will return a NIL as the result. You may specify your own test with the :TEST and :TEST-NOT keywords.

EXAMPLES

(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 COMPATIBILITY: XLISP does not support the :FROM-END, :START, :END, :COUNT and :KEY keywords which Common LISP does.


Go to the first, previous, next, last section, table of contents.