
18 Jul
2007
18 Jul
'07
8:40 a.m.
On 7/18/07, Arie Groeneveld
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