- lseq-member x lseq #!optional predprocedure
- lseq-memq x lseqprocedure
- lseq-memv x lseqprocedure
These procedures return the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-memq uses eq? to compare x with the elements of lseq, while lseq-memv uses eqv?, and lseq-member uses pred, which defaults to equal?.
(lseq-memq 'a '(a b c)) ;=> (a b c) (lseq-memq 'b '(a b c)) ;=> (b c) (lseq-memq 'a '(b c d)) ;=> #f (lseq-memq (list 'a) '(b (a) c)) ;=> #f (lseq-member (list 'a) '(b (a) c)) ;=> ((a) c) (lseq-memq 101 '(100 101 102)) ;=> *unspecified* (lseq-memv 101 '(100 101 102)) ;=> (101 102)
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure, e.g.
(lseq-find-tail even? lseq) ; Find the first elt with an even key.