Lisp Missing Integer
(defun missing-integer (a)
(let ((sorted (sort (remove-duplicates (copy-list a) :test #'=) #'<))
(min 1))
(loop for v in sorted
do (when (> v 0)
(if (/= min v)
(return)
(incf min))))
min))
This records the positive numbers that exist, then returns the smallest positive value that is still missing.