
On Wed, Mar 14, 2007 at 12:09:41AM +0000, Ian Lynagh wrote:
On Tue, Mar 13, 2007 at 11:31:47PM +0000, Neil Mitchell wrote:
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.
That's all true, but I'd still prefer to have nubSorted than sortNub :-)
I dunno. I can't think of a common non-pathological operation that would preserve sorting while adding duplicate elements. not that (map head . group) won't ever come up... but i don't see how it could come up all that often. John -- John Meacham - ⑆repetae.net⑆john⑈