Re: [Haskell-cafe] Time consumption nub

2007-07-19 Thread Arie Groeneveld
I tried this version, > however >>> nsortBy cmp l = mergesort compare l > should be: > > nsortBy cmp l = mergesort cmp l > > Thanks Sorry, with this version I meant: > nsort l = mergesort compare l > nsortBy cmp l = mergesort compare l > > mergesort :: (a -> a -> Ordering) -> [a] -> [a] > merg

Re: [Haskell-cafe] Time consumption nub

2007-07-19 Thread Arie Groeneveld
I tried this version, however >> nsortBy cmp l = mergesort compare l should be: nsortBy cmp l = mergesort cmp l Thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Mirko Rahn
Arie Groeneveld wrote: Ok, so when do I use nub instead of 'map head.group.sort'? Never. If |nub_sort=map head.group.sort| is applicable, then you are dealing with a member of class Ord, so use the O(n*log n) |nub_sort|. If you want to preserve the relative order of the input list, use somet

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread haskell
Arie Groeneveld wrote: Hi, Wondering about time space consuming: 'nub' vs 'map head.group.sort' Consider: ry = [1..1] ++ replicate 13 5 ++ replicate 21 34 *Main> length . nub $ ry 1 (5.18 secs, 105 bytes) *Main> length . map head . group . sort $ ry 1 (0.03 secs, 6293384 b

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Stuart Cook
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 do

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Stefan Holdermans
Arie, Ok, so when do I use nub instead of 'map head.group.sort' ? Well, for one thing, |map head . group . sort| produces a sorted list, wheras |nub| preserves the order of the input list. Cheers, Stefan ___ Haskell-Cafe mailing list Haskell-C

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Arie Groeneveld
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

Re: [Haskell-cafe] Time consumption nub

2007-07-18 Thread Miguel Mitrofanov
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. _

[Haskell-cafe] Time consumption nub

2007-07-18 Thread Arie Groeneveld
Hi, Wondering about time space consuming: 'nub' vs 'map head.group.sort' Consider: ry = [1..1] ++ replicate 13 5 ++ replicate 21 34 *Main> length . nub $ ry 1 (5.18 secs, 105 bytes) *Main> length . map head . group . sort $ ry 1 (0.03 secs, 6293384 bytes) Time sp