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.

remove

remove

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

SYNTAX

(remove <expr>  [ { :test | :test-not }  ] )
        <expr>          -       the expression to remove - an atom or list
        <list-expr>     -       the list to remove from 
        <test>          -       optional test function (default is EQL)

DESCRIPTION

REMOVE searches through <list-expr> for <expr>. If <expr> is found, REMOVE returns the list with the <expr> deleted. All occurances of <expr> are deleted. If <expr> is not found, then the <list-expr> is returned unaltered. You may specify your own test with the :TEST and :TEST-NOT keywords followed by the test you which to perform. Note that this operation is non-destructive, it does not modify or affect <list-expr> directly - it creates a modified copy.

EXAMPLES

(setq mylist '(a b c d it e f))         ; set up a list
(remove 'it mylist)                     ; returns (A B C D E F)
(print mylist)                          ; prints (A B C D IT E F)
                                        ;   note that MYLIST is not
                                        ;   affected 
(setq mylist '(a b c b d b))            ; change list to include
                                        ;   duplicates
(remove 'b mylist)                      ; returns (A C D)
                                        ;
(setq alist '( (a) (b) (it) (c)))       ; set up another list
(remove '(it) alist)                    ; returns ((A) (B) (IT) (C))
                                        ;   the EQ test doesn't work
                                        ;   for lists
(remove '(it) alist :test 'equal)       ; returns ((A) (B) (C))
                                        ;
(setq slist '( "a" "b" "it" "c"))       ; set up yet another list
(remove "it" slist)                     ; returns ("a" "b" "c")
(remove "it" slist :test-not 'equal)    ; returns ("it") - REMOVE
                                        ;   takes away everything but IT

NOTE: The REMOVE 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.