Created
June 19, 2012 01:14
-
-
Save tron1point0/2951757 to your computer and use it in GitHub Desktop.
Point-free style, monads, arrows, and a partridge in a pear tree
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
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