assoc take an alist and a key as
arguments and return the entry for that key if an entry exists, or
#f if there is no entry for that key. Note that, in the cases
where an entry exists, these procedures return the complete entry, that
(KEY . VALUE), not just the value.
Fetch the entry in alist that is associated with key. To decide whether the argument key matches a particular entry in alist,
assqcompares keys with
equal?. If key cannot be found in alist (according to whichever equality predicate is in use), then return
#f. These functions return the entire alist entry found (i.e. both the key and the value).
assoc-ref, on the other
hand, take an alist and a key and return just the value for that
key, if an entry exists. If there is no entry for the specified key,
these procedures return
This creates an ambiguity: if the return value is
#f, it means
either that there is no entry with the specified key, or that there
is an entry for the specified key, with value
assq-ref and friends should only be used where it
is known that an entry exists, or where the ambiguity doesn't matter
for some other reason.
assoc, except that only the value associated with key in alist is returned. These functions are equivalent to(let ((ent (associator key alist))) (and ent (cdr ent)))
where associator is one of