Created
October 10, 2011 14:21
-
-
Save konn/1275438 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 Main where | |
import Data.Maybe | |
import Data.Monoid | |
makeFizz :: Int -> String -> [Maybe String] | |
makeFizz count str = cycle $ Just str : replicate (count - 1) Nothing | |
fizzBuzz :: [(Int, String)] -> [String] | |
fizzBuzz = zipWith fromMaybe (map show [0..]) . foldr (zipWith mappend) (repeat Nothing) . map (uncurry makeFizz) | |
main :: IO () | |
main = mapM_ putStrLn $ tail $ fizzBuzz [(3, "Fizz"), (5, "Buzz")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment