Skip to content

Instantly share code, notes, and snippets.

@algorev
Created June 19, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save algorev/149dddff3c519447b3a99fc0298b0686 to your computer and use it in GitHub Desktop.
Save algorev/149dddff3c519447b3a99fc0298b0686 to your computer and use it in GitHub Desktop.
The code for a Haskell FizzBuzz program
main :: IO ()
main = putStrLn $ unlines fizzbuzz
fizzbuzz :: [String]
fizzbuzz = [if x `dividable` 3
then if x `dividable` 5
then "Fizzbuzz"
else "Fizz"
else "Buzz"
| x <- [1..100], x `dividable` 5 || x `dividable` 3]
dividable :: Int -> Int -> Bool
dividable lop rop = (lop `mod` rop) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment