Infinite fizzbuzz pphetra 16th July, 2008 09:00 (UTC)

I like infinite and lazy so my version is like this.

fizz = concat $ repeat [ “”, “”, “fizz” ]

buzz = concat $ repeat [ “”, “”, “”, “”, “buzz” ]

nums = map show [ 1.. ]

fizzbuzz = zipWith (\n fb -> if fb == “” then n else fb) nums (zipWith (++) fizz buzz)

PS: How can I format code in your blog?

Infinite fizzbuzz Kirit Sælensminde 16th July, 2008 09:12 (UTC)
pphetra said

PS: How can I format code in your blog?

I stole the markdown syntax — prefix each line with four spaces. But there is also a conflict with the mediawiki syntax which uses the square brackets for links, this affects Haskell quite badly, but just put some whitespace inside the square brackets and it should be ok.

To join in the discussion you should register or log in
Infinite fizzbuzz scherrey 16th July, 2008 10:01 (UTC)
hey no fair changing the spec! :)