Function: dash--assoc-fn

dash--assoc-fn is a byte-compiled function defined in dash.el.

Signature

(dash--assoc-fn)

Documentation

Return the flavor of assoc that goes best with -compare-fn.

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun dash--assoc-fn ()
  "Return the flavor of `assoc' that goes best with `-compare-fn'."
  (declare (side-effect-free error-free))
  (let ((cmp -compare-fn))
    (cond ((memq cmp '(nil equal)) #'assoc)
          ((eq cmp #'eq) #'assq)
          ((lambda (key alist)
             ;; Since Emacs 26, `assoc' accepts a custom `testfn'.
             ;; Version testing would be simpler here, but feature
             ;; testing gets more brownie points, I guess.
             (static-if (condition-case nil
                            (assoc nil () #'eql)
                          (wrong-number-of-arguments t))
                 (--first (and (consp it) (funcall cmp (car it) key)) alist)
               (assoc key alist cmp)))))))