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-if

remove-if

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

SYNTAX

(remove-if <test> <list-expr> )
        <test>          -       the test function to be performed
        <list-expr>     -       the list to remove from 

DESCRIPTION

REMOVE-IF searches through <list-expr> and removes any elements that pass the <test>. Note that this operation is non-destructive, it does not modify or affect <list-expr> directly - it creates a modified copy.

EXAMPLES

(setq mylist '(1 2 3 4 5 6 7 8))        ; set up a list
(remove-if 'oddp mylist)                ; returns (2 4 6 8)
(remove-if 'evenp mylist)               ; returns (1 3 5 7)
(print mylist)                          ; prints (1 2 3 4 5 6 7 8)
                                        ;   note that MYLIST is not
                                        ;   affected 
                                        ;
(setq mylist '(a nil b nil c))          ; set up a list
(remove-if 'null mylist)                ; returns (A B C)

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.