RASSOC

look up value in association list
Major Section:  PROGRAMMING

General Forms:
(rassoc x alist)
(rassoc x alist :test 'eql)   ; same as above (eql as equality test)
(rassoc x alist :test 'eq)    ; same, but eq is equality test
(rassoc x alist :test 'equal) ; same, but equal is equality test

(Rassoc x alist) is the first member of alist whose cdr is x, or nil if no such member exists. (rassoc x alist) is thus similar to (assoc x alist), the difference being that it looks for the first pair in the given alist whose cdr, rather than car, is eql to x. See assoc. The optional keyword, :TEST, has no effect logically, but provides the test (default eql) used for comparing x with the cdrs of successive elements of lst.

The guard for a call of rassoc depends on the test. In all cases, the second argument must satisfy alistp. If the test is eql, then either the first argument must be suitable for eql (see eqlablep) or the second argument must satisfy r-eqlable-alistp. If the test is eq, then either the first argument must be a symbol or the second argument must satisfy r-symbol-alistp.

See equality-variants for a discussion of the relation between rassoc and its variants:

(rassoc-eq x lst) is equivalent to (rassoc x lst :test 'eq);

(rassoc-equal x lst) is equivalent to (rassoc x lst :test 'equal).

In particular, reasoning about any of these primitives reduces to reasoning about the function rassoc-equal.

Rassoc is defined by Common Lisp. See any Common Lisp documentation for more information.