Function: rassoc

rassoc is a function defined in fns.c.

Signature

(rassoc KEY ALIST)

Documentation

Return non-nil if KEY is equal to the cdr of an element of ALIST.

The value is actually the first element of ALIST whose cdr equals KEY.

Other relevant functions are documented in the list and alist groups.

View in manual

Probably introduced at or before Emacs version 19.29.

Shortdoc

;; alist
(rassoc 'bar '((foo . bar) (zot . baz)))
    => (foo . bar)
;; list
(rassoc "b" '((1 . "a") (2 . "b")))
    => (2 . "b")

Source Code

// Defined in /usr/src/emacs/src/fns.c
{
  if (eq_comparable_value (key))
    return Frassq (key, alist);
  Lisp_Object tail = alist;
  FOR_EACH_TAIL (tail)
    {
      Lisp_Object car = XCAR (tail);
      if (CONSP (car)
	  && (EQ (XCDR (car), key) || !NILP (Fequal (XCDR (car), key))))
	return car;
    }
  CHECK_LIST_END (tail, alist);
  return Qnil;
}