Last active
May 23, 2016 18:42
-
-
Save cobalamin/37726e3539b1a56cee30793fd9f0e6a3 to your computer and use it in GitHub Desktop.
Yet Another Unnecessary FizzBuzz in Haskell
This file contains hidden or 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
| module RidiculousFizzBuzz where | |
| divBy :: Int -> Int -> Bool | |
| divBy d x = x `mod` d == 0 | |
| fizzIt :: Int -> (Int, Bool, Bool) | |
| fizzIt = (,,) <$> id <*> divBy 3 <*> divBy 5 | |
| fizzString :: (Int, Bool, Bool) -> String | |
| fizzString (x, False, False) = show x | |
| fizzString (_, True, False) = "Fizz" | |
| fizzString (_, False, True) = "Buzz" | |
| fizzString (_, True, True) = "FizzBuzz" | |
| main :: IO () | |
| main = mapM_ (putStrLn . fizzString . fizzIt) [1..100] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment