Created
January 5, 2013 20:57
-
-
Save Wilfred/4463596 to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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