[Haskell-cafe] Re: Generating a random list

apfelmus apfelmus at quantentunnel.de
Sun Mar 2 12:17:09 EST 2008


Albert Y. C. Lai wrote:
> Note the code of "merge":
> 
> merge cmp xs [] = xs
> merge cmp [] ys = ys
> merge cmp (x:xs) (y:ys) = ...
> 
> Suppose you re-order the first two lines, i.e., make it
> 
> merge cmp [] ys = ys
> merge cmp xs [] = xs
> merge cmp (x:xs) (y:ys) = ...
> 
> what will happen?

Oh, so the  mergesort  in the library doesn't behave as nicely as I'd 
have expected. I'd consider the first definition a strictness bug; the 
general etiquette is to force arguments from left to right.


Regards,
apfelmus



More information about the Haskell-Cafe mailing list