Created
October 8, 2009 08:30
-
-
Save javascripter/204864 to your computer and use it in GitHub Desktop.
This file contains 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 Program () where | |
import Control.Monad | |
main :: IO () | |
main = let | |
a = [1..100] | |
fizz = do | |
s <- a | |
guard $ s `mod` 3 == 0 | |
return s | |
buzz = do | |
s <- a | |
guard $ s `mod` 5 == 0 | |
return s | |
in mapM_ (\i -> do { | |
putStr $ show i; | |
if i `elem` fizz then putStr " Fizz" else return (); | |
if i `elem` buzz then putStr " Buzz" else return (); | |
putChar '\n' | |
}) a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment