chickadee » scheme » memv

memq obj listprocedure
memv obj listprocedure
member obj listprocedure

These procedures return the first sublist of list whose car is obj, where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Memq uses eq? to compare obj with the elements of list, while memv uses eqv? and member uses equal?.

(memq 'a '(a b c))                      ===>  (a b c)
(memq 'b '(a b c))                      ===>  (b c)
(memq 'a '(b c d))                      ===>  #f
(memq (list 'a) '(b (a) c))             ===>  #f
(member (list 'a)
        '(b (a) c))                     ===>  ((a) c)
(memq 101 '(100 101 102))               ===>  unspecified
(memv 101 '(100 101 102))               ===>  (101 102)