Skip to content

Instantly share code, notes, and snippets.

@sleibrock
Created July 28, 2016 22:03
Show Gist options
  • Save sleibrock/2f6c3acb265f5cda27fc18bc8db0d1c7 to your computer and use it in GitHub Desktop.
Save sleibrock/2f6c3acb265f5cda27fc18bc8db0d1c7 to your computer and use it in GitHub Desktop.
FizzBuzz with Haskell
-- 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