Skip to content

Instantly share code, notes, and snippets.

@tcql
Created January 26, 2012 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcql/1680673 to your computer and use it in GitHub Desktop.
Save tcql/1680673 to your computer and use it in GitHub Desktop.
the Fizz Buzz problem, solved in Haskell
import Control.Monad (mapM_)
fizzbuzz = [0..100] >>= \x -> return (
case (x `mod` 3, x `mod` 5) of
(0,0) -> "FizzBuzz";
(0,_) -> "Fizz";
(_,0) -> "Buzz";
(_,_) -> show x)
main = mapM_ putStrLn fizzbuzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment