Last active
January 1, 2022 23:33
-
-
Save dreum/0a2045f919d1336c6ffc8e0d70737781 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
import Data.Maybe | |
fizzBuzz n = | |
let | |
base divisor s = | |
if (n `mod` divisor) == 0 | |
then Just s | |
else Nothing | |
maybeFizz = base 3 "Fizz" | |
maybeBuzz = base 5 "Buzz" | |
in fromMaybe (show n) (maybeFizz <> maybeBuzz) | |
main = mapM_ (putStrLn . fizzBuzz) [1..100] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment