0 Members and 1 Guest are viewing this topic.
;; Count Items - Lee Mac;; Returns a list of dotted pairs detailing the number of;; occurrences of each item in a supplied list.(defun LM:CountItems ( l / c x ) (if (setq x (car l)) (progn (setq c (length l) l (vl-remove x (cdr l)) ) (cons (cons x (- c (length l))) (LM:CountItems l)) ) ))
(LM:CountItems '("A" "B" "B" "B" "C" "C" "D" "E" "E" "E" "E"))=> (("A" . 1) ("B" . 3) ("C" . 2) ("D" . 1) ("E" . 4))(LM:CountItems '(1 2 3 3 3 4 5 6 6 7 8 8 8 8))=> ((1 . 1) (2 . 1) (3 . 3) (4 . 1) (5 . 1) (6 . 2) (7 . 1) (8 . 4))
Just use count items by Lee Mac
Sorry, no time to look at code but what happens in the following situation?11, 11, 33, 33, 54Should be: (11, 33)