XLISP remove-if

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# remove-if

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

## Syntax

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

## Description

The 'remove-if' function 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: XLISP does not support the ':from-end', ':start', ':end', ':count' and ':key' keywords which Common Lisp does.

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

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference