Created
June 19, 2017 19:50
-
-
Save algorev/149dddff3c519447b3a99fc0298b0686 to your computer and use it in GitHub Desktop.
The code for a Haskell FizzBuzz program
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
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