chickadee » ck-macros » c-assoc

(c-assoc KEY ALIST) → pair or '#fsyntax
(c-assoc KEY ALIST '(OP ...)) → pair or '#fsyntax

Searches ALIST for the first pair whose car matches KEY, then yields that pair. Yields '#f if no match is found. ALIST must be an association list, i.e. a list of pairs.

Uses '(OP ...) for comparison, or '(c-sym-equal?) if '(OP ...) is omitted.

Analogous to assoc from SRFI-1.

(ck () (c-quote (c-assoc 'x '((a . 1) (b . 2) (a . 3)))))
;; ==> '#f
(ck () (c-quote (c-assoc 'a '((a . 1) (b . 2) (a . 3)))))
;; ==> '(a . 1)
(ck () (c-quote (c-assoc '(a) '((a . 1) (b . 2) ((a) . 3)))))
;; ==> '((a) . 3)