Haskell Distinct
import qualified Data.Set as Set

distinct :: [Int] -> Int
distinct a = Set.size (Set.fromList a)

This counts unique values by tracking what has already been seen.