Lisp Odd Occurrences In Array
(defun odd-occurrences-in-array (a)
(let ((counts (make-hash-table :test 'eql)))
(dolist (v a)
(incf (gethash v counts 0)))
(loop for v being the hash-keys of counts using (hash-value c)
when (oddp c)
return v)))
This uses XOR to cancel out pairs, leaving only the value that appears an odd number of times.