[Haskell-cafe] Hamming's Problem

Dougal Stanton ithika at gmail.com
Fri Jan 18 08:26:43 EST 2008


On 18/01/2008, Bertram Felgenhauer <bertram.felgenhauer at googlemail.com> wrote:

> I have some ideas, but maybe you want to work on a correct solution
> first?

There is an implementation on the wikipedia article for Haskell:

hamming = 1 : map (2*) hamming `merge` map (3*) hamming `merge` map (5*) hamming
     where merge (x:xs) (y:ys)
            | x < y = x : xs `merge` (y:ys)
            | x > y = y : (x:xs) `merge` ys
            | otherwise = x : xs `merge` ys

-- 
Dougal Stanton
dougal at dougalstanton.net // http://www.dougalstanton.net


More information about the Haskell-Cafe mailing list