Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Created January 5, 2013 20:57
Show Gist options
  • Save Wilfred/4463596 to your computer and use it in GitHub Desktop.
Save Wilfred/4463596 to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell
import Control.Monad(forM_)
main = forM_ (take 100 fizzBuzzes) putStrLn
toFizzBuzz :: Integer -> String
toFizzBuzz x
| x `rem` 15 == 0 = "FizzBuzz"
| x `rem` 5 == 0 = "Buzz"
| x `rem` 3 == 0 = "Fizz"
| otherwise = show x
fizzBuzzes = map toFizzBuzz [1..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment