;;; HASH TABLES 3: COUNTING (solution) (defun tally (xs) (let ((table (make-hash-table))) (dolist (x xs) (incf (gethash x table 0))) table)) ;;; ------------------------------------------------------------------ ;;; Checks. Read them - they tell you what to aim for - but leave ;;; them unchanged. ;;; ------------------------------------------------------------------ (check (let ((table (tally '(a b a c a b)))) (and (eql 3 (gethash 'a table)) (eql 2 (gethash 'b table)) (eql 1 (gethash 'c table)) (eql 3 (hash-table-count table)))))