On 7/18/07, Arie Groeneveld <[EMAIL PROTECTED]> wrote:
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.

Well, nub is non-strict, so you can use it on infinite or partial
lists, provided you don't consume too much of the result.

e.g.

 Prelude Data.List> take 10 $ nub [1..]
 [1,2,3,4,5,6,7,8,9,10]

 Prelude Data.List> take 10 $ map head . group . sort $ [1..]
 Interrupted.

(Yes, taking nub of [1..] is silly; it's just an example.)


Stuart
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to