Last active
June 28, 2017 11:36
-
-
Save ethagnawl/85679266fd35194026f540f0baf28709 to your computer and use it in GitHub Desktop.
basic haskell fizzbuzz
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
fizz :: Integer -> String | |
fizz n = if ((n `mod` 3) == 0) | |
then "fizz" | |
else "" | |
buzz :: Integer -> String | |
buzz n = if ((n `mod` 5) == 0) | |
then "buzz" | |
else "" | |
fizzbuzz :: Integer -> String | |
fizzbuzz n = if fizz' ++ buzz' == "" | |
then (show n) | |
else fizz' ++ buzz' | |
where fizz' = fizz n | |
buzz' = buzz n | |
main = do | |
let fizzbuzz'd = map fizzbuzz [1 .. 100] | |
putStrLn $ show fizzbuzz'd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment