- imember x ilist #!optional =procedure
- imemq x ilistprocedure
- imemv x ilistprocedure
These procedures return the first sub-ilist of ilist whose icar is x, where the sub-ilists of ilist are the non-empty ilists returned by (idrop ilist i) for i less than the length of ilist. If x does not occur in ilist, then #f is returned. imemq uses eq? to compare x with the elements of ilist, while imemv uses eqv?, and imember uses equal?.
(imemq 'a (iq a b c)) ;=> (a b c) (imemq 'b (iq a b c)) ;=> (b c) (imemq 'a (iq b c d)) ;=> #f (imemq (list 'a) (ilist 'b '(a) 'c)) ;=> #f (imember (list 'a) (ilist 'b '(a) 'c))) ;=> ((a) c) (imemq 101 (iq 100 101 102)) ;=> *unspecified* (imemv 101 (iq 100 101 102)) ;=> (101 102)
The comparison procedure is used to compare the elements ei of ilist to the key x in this way:
(= x ei) ; ilist is (E1 ... En)
That is, the first argument is always x, and the second argument is one of the ilist elements. Thus one can reliably find the first element of ilist that is greater than five with (imember 5 ilist <)
Note that fully general ilist searching may be performed with the ifind-tail and ifind procedures, e.g.
(ifind-tail even? ilist) ; Find the first elt with an even key.