Here is a useful function made by Lee Mac:
;; 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 l r x
) )
)
)
; Example
(LM:CountItems '("A" "B" "B" "B" "C" "C" "D" "E" "E" "E" "E"))
=> (("A" . 1) ("B" . 3) ("C" . 2) ("D" . 1) ("E" . 4))
Please show how to modify this function to get the result:
; if we have a list
(("a" "1") ("b" "2") ("c" "3")("d" "6"))
(("a" "2") ("b" "4") ("c" "5")("d" "4"))
(("a" "2") ("b" "4") ("c" "5")("d" "2"))
(("a" "3") ("b" "3") ("c" "6")("d" "3"))
)
)
; new function
(LM:CountItems_by_member lst
(list "a" "b" "c") ) => (
(("a" "1") ("b" "2") ("c" "3")("count" "1"))
(("a" "2") ("b" "4") ("c" "5")("count" "2"))
(("a" "3") ("b" "3") ("c" "6")("count" "1"))
)