SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
<<[assp] | [Index] | [assv]>> |
Conformance: R5RS 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))
Assq
returns the first association whose key is identical
to a given symbol.
Arguments:
X - key of value to be found
A - association list
Implementation:
(define (assq x a) (cond ((null? a) #f) ((eq? (caar a) x) (car a)) (else (assq x (cdr a)))))
Example:
(assq 'c '((a . i) (b . ii) (c . iii) (d . iv))) => (c . iii)
<<[assp] | [Index] | [assv]>> |