Skip to content

Instantly share code, notes, and snippets.

@tron1point0
Created June 19, 2012 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tron1point0/2951757 to your computer and use it in GitHub Desktop.
Save tron1point0/2951757 to your computer and use it in GitHub Desktop.
Point-free style, monads, arrows, and a partridge in a pear tree
import Control.Monad
import Control.Arrow
import Data.Monoid
import Data.List(unlines)
import System.Environment(getArgs)
fizzbuzz = uncurry (flip maybe id) . (arr show &&& arr forb)
where tests = map ((.) (==0) . flip mod) [3,5]
fb = map Just ["Fizz","Buzz"]
forb = mconcat . zipWith (flip (>>)) fb . map guard . zipWith ($) tests . repeat
main = getArgs >>= putStr . unlines . flip take (map fizzbuzz [1..]) . read . head . (++["100"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment