rassoc, rassoc-if, rassoc-if-not
rassoc item alist &key key test test-not → entry
rassoc-if predicate alist &key key → entry
rassoc-if-not predicate alist &key key → entry
item—an object.
alist—an association list.
predicate—a designator for a function of one argument that returns a generalized boolean.
test—a designator for a function of two arguments that returns a generalized boolean.
test-not—a designator for a function of two arguments that returns a generalized boolean.
key—a designator for a function of one argument, or nil.
entry—a cons that is an element of the alist, or nil.
15.6.0 13rassoc, rassoc-if, and rassoc-if-not return the first cons whose cdr satisfies the test. If no such cons is found, nil is returned.
Removed per X3J13. -kmp 05-Oct-93 The argument to \param{predicate} is an element of \param{alist} as returned by the \kwd{key} function (if supplied). The arguments to \kwd{test} and \kwd{test-not} are \param{item} and an element of \param{alist} as returned by the \kwd{key} function (if supplied), in that order. If \kwd{key} is supplied, it is applied to the \term{cdr} of the \param{alist} entries and the result is passed to the \param{predicate}, \kwd{test}, or \kwd{test-not} function. The \term{cdr} of the \param{alist} entry contains the key of the association, and if \kwd{key} is not supplied or \nil, the \term{cdr} is the key of the association.
If nil appears in alist in place of a pair, it is ignored.
(setq alist '((1 . "one") (2 . "two") (3 . 3))) → ((1 . "one") (2 . "two") (3 . 3)) (rassoc 3 alist) → (3 . 3) (rassoc "two" alist) → NIL (rassoc "two" alist :test 'equal) → (2 . "two") (rassoc 1 alist :key #'(lambda (x) (if (numberp x) (/ x 3)))) → (3 . 3) (rassoc 'a '((a . b) (b . c) (c . a) (z . a))) → (C . A) (rassoc-if #'stringp alist) → (1 . "one") (rassoc-if-not #'vectorp alist) → (3 . 3)
None.
None.
None.
assoc, Section 3.6 (Traversal Rules and Side Effects)
The :test-not parameter is deprecated.
The function rassoc-if-not is deprecated.
It is possible to rplaca the result of rassoc, provided that it is not nil, in order to “update” alist.
15.6.0 13
The expressions
(rassoc item list :test fn)and
(find item list :test fn :key #'cdr)are equivalent in meaning, except when the
item is nil and nil appears in place of a pair in the alist. See the function assoc.