| item | a key object |
| alist | alist - list of cons cell with key-value pairs |
| key | function for extracting key before test |
| test | function key and item comparison |
ASSOC function searches supplied list for cons cell that have item as car part. Return value is the cell with key-value pair which key matched testing conditions, otherwise NIL. Default comparison operator is EQL.
Associative list, or for short alist, is a list with key-value pairs in cons cells. That is ((key1 . value1) (key2 . value2) ...)
(assoc 'a '((a . 1) (b . 2) (c . 3))) => (A . 1)
(assoc 'x '((a . 1) (b . 2) (c . 3))) => NIL
(assoc 'b '((a . 1) (b . 2) (c . 3) (b . 4))) => (B . 2)
(assoc "b" '(("a" . 1) ("b" . 2))) => NIL
(assoc "b" '(("a" . 1) ("b" . 2)) :test #'equal) => ("b" . 2)
(assoc 7 '((6 . a) (9 . b)) :key #'1+) => (6 . A)
(assoc 5 nil) => NIL