XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

remove-if-not


Type:   -   function (subr)
Source:   -   xllist.c

Syntax

(remove-if-not test list-expr)
test - the test function to be performed
list-expr - the list to remove from
returns - a copy of list-expr with non-matching elements removed

Description

The 'remove-if-not' function searches through 'list-expr' and removes any elements that fail 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-not 'oddp mylist)       ; returns (1 3 5 7)
(remove-if-not 'evenp mylist)      ; returns (2 4 6 8)
(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-not 'null mylist)       ; returns (NIL NIL)

Common Lisp: XLISP does not support the ':from-end', ':start', ':end', ':count' and ':key' keywords which Common Lisp does.

See the remove-if-not function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next