fork download
  1. (defun count-unique-values (list)
  2. (let ((map (make-hash-table)))
  3. (loop for x in list
  4. do (setf (gethash x map) 1))
  5. (hash-table-count map)))
  6.  
  7.  
  8. (defun test (list)
  9. (format t "Testing ~a: ~a ~%" list (count-unique-values list)))
  10.  
  11. (test '(1 2 3))
  12. (test '(1 2 3 3))
  13. (test '(1 1 2 2 3 3))
  14.  
  15.  
  16.  
  17.  
Success #stdin #stdout 0s 10520KB
stdin
Standard input is empty
stdout
Testing (1 2 3): 3 
Testing (1 2 3 3): 3 
Testing (1 1 2 2 3 3): 3