Skip to content

Instantly share code, notes, and snippets.

@konn
Created October 10, 2011 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save konn/1275438 to your computer and use it in GitHub Desktop.
Save konn/1275438 to your computer and use it in GitHub Desktop.
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