BTW, I notice that your merges, like mine, are left-biased. This is a
useful property (my callers require it), and doesn't seem to cost
anything to implement, so maybe you could commit to it in the
documentation?
By left-biased I mean that when elements compare equal, pick the
leftmost one, e.g.
Leon Smith wrote:
On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:
Ah, I meant to use the union' from your previous message, but I think
that doesn't work because it doesn't have the crucial property that the case
union (VIP x xs) ys = ...
does not
On Thu, Feb 18, 2010 at 8:07 AM, Evan Laforge qdun...@gmail.com wrote:
And BTW again, here's something I've occasionally found useful:
-- | Handy to merge or sort a descending list.
reverse_compare :: (Ord a) = a - a - Ordering
reverse_compare a b = case compare a b of
LT - GT
EQ - EQ
On Thu, Feb 18, 2010 at 2:32 AM, Evan Laforge qdun...@gmail.com wrote:
By purest coincidence I just wrote the exact same function (the simple
mergeAll', not the VIP one). Well, extensionally the same...
intensionally mine is 32 complicated lines and equivalent to the 3
line mergeAll'. I even
On Thu, Feb 18, 2010 at 3:07 AM, Evan Laforge qdun...@gmail.com wrote:
BTW, I notice that your merges, like mine, are left-biased. This is a
useful property (my callers require it), and doesn't seem to cost
anything to implement, so maybe you could commit to it in the
documentation?
Also, I
On Thu, Feb 18, 2010 at 5:22 PM, Leon Smith leon.p.sm...@gmail.com wrote:
On Thu, Feb 18, 2010 at 3:07 AM, Evan Laforge qdun...@gmail.com wrote:
BTW, I notice that your merges, like mine, are left-biased. This is a
useful property (my callers require it), and doesn't seem to cost
anything to
Leon Smith wrote:
Heinrich Apfelmus wrote:
I see no obvious deficiencies. :) Personally, I'd probably structure it like
http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap
This variant, based on the wiki article, is cleaner, slightly
simpler, appears to be just as fast,
The easiest solution is simply to define
unionAll = nub . mergeAll
where
-- specialized definition of nub
nub = map head . groupBy (==)
Talking about the easiest solution, I guess this is a quite easy way of
defining unionAll as well: http://gist.github.com/306782
Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun:
The easiest solution is simply to define
unionAll = nub . mergeAll
where
-- specialized definition of nub
nub = map head . groupBy (==)
Talking about the easiest solution, I guess this is a quite easy
Ooops I thought the inner lists are possibly of infinite size.
On 17 February 2010 17:16, Daniel Fischer daniel.is.fisc...@web.de wrote:
Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun:
The easiest solution is simply to define
unionAll = nub . mergeAll
where
Am Mittwoch 17 Februar 2010 18:59:42 schrieb Ozgur Akgun:
Ooops I thought the inner lists are possibly of infinite size.
Both, I think.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:
Ah, I meant to use the union' from your previous message, but I think
that doesn't work because it doesn't have the crucial property that the case
union (VIP x xs) ys = ...
does not pattern match on the
On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus
apfel...@quantentunnel.de wrote:
Ah, I meant to use the union' from your previous message, but I think
that doesn't work because it doesn't have the crucial property that the case
union (VIP x xs) ys = ...
does not pattern match on the
By purest coincidence I just wrote the exact same function (the simple
mergeAll', not the VIP one). Well, extensionally the same...
intensionally mine is 32 complicated lines and equivalent to the 3
line mergeAll'. I even thought of short solution by thinking that
pulling the first element
Leon Smith wrote:
With the urging and assistance of Omar Antolín Camarena, I will be
adding two functions to data-ordlist: mergeAll and unionAll, which
merge (or union) a potentially infinite list of potentially infinite
ordered lists, under the assumption that the heads of the non-empty
I see no obvious deficiencies. :) Personally, I'd probably structure it like
http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap
This variant, based on the wiki article, is cleaner, slightly
simpler, appears to be just as fast, and allocates slightly less
memory:
import
16 matches
Mail list logo