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
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
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
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
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
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
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
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.
_
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