
13 Mar
2007
13 Mar
'07
7:31 p.m.
Hi
nubSorted :: Eq a => [a] -> [a] nubSorted (x1:x2:xs) | x1 == x2 = nubSorted (x1:xs) nubSorted (x:xs) = x : nubSorted xs nubSorted [] = []
I considered this, but nubSorted imposes a precondition, sortNub ensures a postcondition. As an interface goes sortNub is harder to get wrong. Plus sortNub is likely to be substantially more efficient than nubSorted . sort - to the point where nubSorted . sort is likely to be slower than a normal nub. Thanks Neil