Skip to content

Instantly share code, notes, and snippets.

@tanakh
Created December 17, 2013 14:51
Show Gist options
  • Save tanakh/8006086 to your computer and use it in GitHub Desktop.
Save tanakh/8006086 to your computer and use it in GitHub Desktop.
fizzbuzz
fizzbuzz :: Int -> String
fizzbuzz n = fromMaybe (show n) $
(guard (n `mod` 3 == 0) >> pure "Fizz") <>
(guard (n `mod` 5 == 0) >> pure "Buzz")
main :: IO ()
main = forM_ [1..100] $ putStrLn . fizzbuzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment