Last active
August 29, 2015 13:55
-
-
Save ajnsit/8734418 to your computer and use it in GitHub Desktop.
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
-- What is the big deal? Took all of 2 minutes to write this | |
module Main where | |
main :: IO () | |
main = mapM_ (putStrLn . fizzbuzz) [1..100] | |
fizzbuzz :: Int -> String | |
fizzbuzz x = divisors `orElse` show x | |
where | |
divisors = concatMap test [(3,"Fizz"),(5,"Buzz"),(7,"Baz")] | |
test (i,s) = if x `mod` i == 0 then s else "" | |
orElse [] a = a | |
orElse a _ = a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment