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
5
Task/FizzBuzz/Haskell/fizzbuzz-2.hs
Normal file
5
Task/FizzBuzz/Haskell/fizzbuzz-2.hs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
main = mapM_ putStrLn $ take 100 fizzbuzz
|
||||
|
||||
fizzbuzz = zipWith (\x y -> if null y then show x else y) [1..] fbs
|
||||
|
||||
fbs = zipWith (++) (cycle ["","","Fizz"]) (cycle ["","","","","Buzz"])
|
||||
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"
|
||||
6
Task/FizzBuzz/Haskell/fizzbuzz-4.hs
Normal file
6
Task/FizzBuzz/Haskell/fizzbuzz-4.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
fizzBuzz :: Int -> String
|
||||
fizzBuzz x
|
||||
| x `mod` 5 == 0 && x `mod` 3 == 0 = "FizzBuzz"
|
||||
| x `mod` 5 == 0 = "Buzz"
|
||||
| x `mod` 3 == 0 = "Fizz"
|
||||
| otherwise = show x
|
||||
7
Task/FizzBuzz/Haskell/fizzbuzz.hs
Normal file
7
Task/FizzBuzz/Haskell/fizzbuzz.hs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
main = mapM_ (putStrLn . fizzbuzz) [1..100]
|
||||
|
||||
fizzbuzz x
|
||||
| x `mod` 15 == 0 = "FizzBuzz"
|
||||
| x `mod` 3 == 0 = "Fizz"
|
||||
| x `mod` 5 == 0 = "Buzz"
|
||||
| otherwise = show x
|
||||
Loading…
Add table
Add a link
Reference in a new issue