Created
November 19, 2021 18:21
-
-
Save binq/f3db804c0e15fea813538483925c260a 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
both :: Maybe a -> Maybe a -> Bool | |
both (Just _) (Just _) = True | |
both _ _ = False | |
f n = | |
let | |
f = bool Nothing (Just Fizz) (n % 3 == 0) | |
b = bool Nothing (Just Buzz) (n % 5 == 0) | |
u = bool Nothing (Just FizzBuzz) (all isJust [f, b]) | |
g = bool Nothing (Just (Got n)) (all isNone [f, b]) | |
in find isJust [g, u, b, f] | |
fizzBuzz = fmap f [1..] | |
main = show . take 5 $ fizzBuzz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment