[Haskell-cafe] Hamming's Problem
bertram.felgenhauer at googlemail.com
Tue Jan 22 05:08:20 EST 2008
> merge' (x:xs) ys = x : merge xs ys
> hammingx = 1 : foldr1 merge' [map (h x) hammingx | x <- hammingx]
Sorry. 'foldr1' is still slightly too strict. (Why doesn't the Haskell
report define foldr1 in terms of foldr?)
The code that works is
marge'  ys = ys
merge' (x:xs) ys = x : merge xs ys
hammingx = 1 : foldr merge'  [map (h x) hammingx | x <- hammingx]
I had tested that version, but I assumed the foldr1 version would
> which actually works.
And I wrote that without testing. Shame on me.
More information about the Haskell-Cafe