SketchyLISP Reference |
Copyright (C) 2006 Nils M Holm |
<<[member] | [Index] | [min]>> |
Conformance: R5RS
Purpose:
Check whether a list has a member that is identical to a
given symbol. If such a member exists, return the tail of
the list beginning with that member. If no such member is
found, return
#f.
Arguments:
X - symbol to find
A - list
Model:
(define (memq x a) (cond ((null? a) #f) ((eq? (car a) x) a) (#t (memq x (cdr a)))))
Implementation:
(define (memq x a) (letrec ((_memq (lambda (a) (cond ((null? a) #f) ((eq? (car a) x) a) (#t (_memq (cdr a))))))) (_memq a)))
Example:
(memq 'c '(a b c d e f)) => (c d e f)
<<[member] | [Index] | [min]>> |