1 2 3 4 5 6 7 8 9 10 11 12 13 14

module Main where import Data.List -- | Minimally exclusive member of a set (i.e., list) mex :: [Int] -> Int mex xs = f (sort $ nub xs) 0 where f [] a = a f (x:xs) a | x > a = f xs a | otherwise = f xs $ succ a main :: IO () main = do print $ mex [0, 1, 1, 1]

1

2