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.

member

member

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

SYNTAX

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

DESCRIPTION

MEMBER searches through <list-expr> for <expr>. If found, MEMBER returns the remainder of the <list-expr> starting with <expr>. If <expr> is not found, a NIL is returned. You may specify your own test with the :TEST and :TEST-NOT keywords followed by the test you which to perform.

EXAMPLES

(member 'a '(1 2 3 4))                  ; returns NIL
(member '2 '(1 2 3 4))                  ; returns (2 3 4)
                                        ;
(setq mylist '(2 4 8 16 32 64 128 256)) ; make a numeric list
(member 6 mylist :test '<)              ; returns (8 16 32 64 128 256)
(member 6 (reverse mylist) :test-not '<); returns (4 2)
(member '20 '(60 40 20 10) :test '> )   ; returns (10)
                                        ;
(member '(a) '((see) (a) (cat))         ; returns ((A) (CAT))
              :test 'equal)             ;   note EQUAL as test
(member "hi" '("a" "hi" "c")            ; returns ("hi" "c")
        :test 'string= )                ;   note STRING= as test

NOTE: The MEMBER 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: Common LISP supports the use of the :KEY keyword which specifies a function that is applied to each element of <list-expr> before it is tested. XLISP does not support this.


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