Skip to content

Instantly share code, notes, and snippets.

@ajnsit
Last active August 29, 2015 13:55
Show Gist options
  • Save ajnsit/8734418 to your computer and use it in GitHub Desktop.
Save ajnsit/8734418 to your computer and use it in GitHub Desktop.
-- 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