Friday, April 26, 2019

emacs lisp count unique items in list (elisp)


(let (items)
  (dolist (item (list ... put some list of items here ...))
    (let ((match (assoc item items)))
      (if match
          (setcdr match (1+ (cdr match)))
        (push (cons item 1) items))))

  (print items))

No comments:

Post a Comment