[Haskell-cafe] Short and sweet

Paul Johnson paul at cogito.org.uk
Fri May 18 16:05:47 EDT 2007


Andrew Coppin wrote:
> It occurs to me that if you want a sorted list of only unique 
> elements, it would seem (to me) to be efficient to do the sorting and 
> the uniquing at the same time. Does any library function do this? (I 
> imagine it wouldn't be hard to write it yourself...)
Yes, although it only works on instances of Ord then, because of the 
sorting.

Its actually quite a common idiom, and worth figuring out for yourself.  
Hint: look at "group".

Paul.


More information about the Haskell-Cafe mailing list