[Haskell-cafe] Time consumption nub

Arie Groeneveld bradypus at xs4all.nl
Wed Jul 18 08:28:36 EDT 2007


Miguel Mitrofanov wrote:
> AG> Wondering about time space consuming: 'nub' vs 'map
> AG> head.group.sort'
>
> Prelude> :t Data.List.nub
> Data.List.nub :: (Eq a) => [a] -> [a]
> Prelude> :t Data.List.sort
> Data.List.sort :: (Ord a) => [a] -> [a]
>
> nub uses less information than sort, so it MUST be slower.
Ok, so when do I use nub instead of 'map head.group.sort' ?

Using nub gave me a lot of trouble in terms of time consumption
while handling long lists.

@@i=arie



More information about the Haskell-Cafe mailing list