Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/FizzBuzz/Haskell/fizzbuzz-7.hs
Normal file
12
Task/FizzBuzz/Haskell/fizzbuzz-7.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