SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
<<[assoc] | [Index] | [assq]>> |
Conformance: R5.91RS Scheme
Purpose:
Retrieve an association from an association list.
An association list is a list of pairs where
the
car
part of each pair holds a key and the
cdr
part of the pair holds the value
associated with that key:
((key1 . value1) ... (keyN . valueN))
Assp
returns the first association whose key matches a given
predicate.
Arguments:
P - predicate
A - association list
Implementation:
(define (assp p a) (cond ((null? a) #f) ((p (caar a)) (car a)) (else (assp p (cdr a)))))
Example:
(assp even? '((1 . i) (2 . ii) (3 . iii) (4 . iv))) => (2 . ii)
See also:
assoc,
assq,
assv,
memp.
<<[assoc] | [Index] | [assq]>> |