Function: helpful--count-values

helpful--count-values is a byte-compiled function defined in helpful.el.

Signature

(helpful--count-values ITEMS)

Documentation

Return an alist of the count of each value in ITEMS.

E.g. (x x y z y) -> ((x . 2) (y . 2) (z . 1))

Source Code

;; Defined in ~/.emacs.d/elpa/helpful-20250408.334/helpful.el
(defun helpful--count-values (items)
  "Return an alist of the count of each value in ITEMS.
E.g. (x x y z y) -> ((x . 2) (y . 2) (z . 1))"
  (let (counts)
    (dolist (item items (nreverse counts))
      (-if-let (item-and-count (assoc item counts))
          (setcdr item-and-count (1+ (cdr item-and-count)))
        (push (cons item 1) counts)))))