Function: cl-assoc

cl-assoc is an autoloaded and byte-compiled function defined in cl-seq.el.gz.

Signature

(cl-assoc ITEM LIST [KEYWORD VALUE]...)

Documentation

Find the first item whose car matches ITEM in LIST.

Keywords supported: :test :test-not :key

View in manual

Aliases

assoc* (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-seq.el.gz
;;;###autoload
(defun cl-assoc (item alist &rest cl-keys)
  "Find the first item whose car matches ITEM in LIST.
\nKeywords supported:  :test :test-not :key
\n(fn ITEM LIST [KEYWORD VALUE]...)"
  (declare (important-return-value t)
           (compiler-macro cl--compiler-macro-assoc))
  (if cl-keys
      (cl--parsing-keywords (:test :test-not :key :if :if-not) ()
        (while (and alist
                    (or (not (consp (car alist)))
                        (not (cl--check-test item (car (car alist))))))
          (setq alist (cdr alist)))
        (and alist (car alist)))
    (if (and (numberp item) (not (fixnump item)))
        (assoc item alist)
      (assq item alist))))