Created
July 28, 2016 22:03
-
-
Save sleibrock/2f6c3acb265f5cda27fc18bc8db0d1c7 to your computer and use it in GitHub Desktop.
FizzBuzz with Haskell
This file contains 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
-- Fizzbuzzing | |
fizzBuzz True False _ = "Fizz" | |
fizzBuzz False True _ = "Buzz" | |
fizzBuzz True True _ = "FizzBuzz" | |
fizzBuzz _ _ x = show x | |
main = do | |
mapM_ putStrLn [fizzBuzz (three x) (five x) x | x <- [1..100]] | |
where | |
three n = n `mod` 3 == 0 | |
five n = n `mod` 5 == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment