[Haskell-cafe] Perfect example

Miguel Mitrofanov miguelimo38 at yandex.ru
Fri Aug 3 01:59:34 EDT 2007

BP> If I want a small example to show to people I usually use zipWith.

I'd suggest unfoldr + lazyness, such as

hammings = 1 : unfoldr (Just . generator) (map (\n -> map (n*) hammings) [2,3,5])
    where generator xss =
        let x = minimum $ map head xss
        in (x, map (dropWhile (x==)) xss)

I guess, it's tough to reproduce even in languages like Prolog.

More information about the Haskell-Cafe mailing list