Created
June 22, 2016 20:18
-
-
Save programaths/7c598608fda2dc4fc42fb2c3eaab82dd to your computer and use it in GitHub Desktop.
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
-- V1 | |
[ if x `mod` 3 == 0 then | |
"Fizz" | |
else | |
if x `mod` 5 == 0 then | |
"Buzz" | |
else | |
if x `mod` 15 == 0 then | |
"FizzBuzz" | |
else show x | |
| x <- [1..16] ] | |
-- V2 | |
fizzBuzz :: Int -> String | |
fizzBuzz n | |
| mult15 = "FizzBuzz" | |
| mult3 = "Fizz" | |
| mult5 = "Buzz" | |
| otherwise = show n | |
where mult15 = n `mod` 15 == 0 | |
mult5 = n `mod` 5 == 0 | |
mult3 = n `mod` 3 == 0 | |
map fizzBuzz [1..16] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment