First commit of partial RosettaCode contents.
Pushing this for testing purposes. Lots of work still needed.
This commit is contained in:
commit
1e05ecd7ee
781 changed files with 9080 additions and 0 deletions
12
Task/FizzBuzz/Haskell/fizzbuzz-3.hs
Normal file
12
Task/FizzBuzz/Haskell/fizzbuzz-3.hs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import Control.Monad.State
|
||||
import Control.Monad.Trans
|
||||
import Control.Monad.Writer
|
||||
|
||||
main = putStr $ execWriter $ mapM_ (flip execStateT True . fizzbuzz) [1..100]
|
||||
|
||||
fizzbuzz :: Int -> StateT Bool (Writer String) ()
|
||||
fizzbuzz x = do
|
||||
when (x `mod` 3 == 0) $ tell "Fizz" >> put False
|
||||
when (x `mod` 5 == 0) $ tell "Buzz" >> put False
|
||||
get >>= (flip when $ tell $ show x)
|
||||
tell "\n"
|
||||
Loading…
Add table
Add a link
Reference in a new issue