Proposal: Add Data.List.sortNub and sortNubBy

Ian Lynagh igloo at earth.li
Tue Mar 13 18:39:48 EDT 2007


On Tue, Mar 13, 2007 at 03:16:44AM +0000, Neil Mitchell wrote:
> 
> I propose the addition of sortNub and sortNubBy.

I would rather see

    nubSorted :: Eq a => [a] -> [a]
    nubSorted (x1:x2:xs)
     | x1 == x2 = nubSorted (x1:xs)
    nubSorted (x:xs) = x : nubSorted xs
    nubSorted [] = []

You can then nubSorted . sort, but you can also use it on data that you
know is already sorted (or at least data in which all the dupes you want
to eliminate are in clumps).


Thanks
Ian



More information about the Libraries mailing list