Skip to content

Instantly share code, notes, and snippets.

@NicolasT
Created April 3, 2010 21:58
Show Gist options
  • Select an option

  • Save NicolasT/354885 to your computer and use it in GitHub Desktop.

Select an option

Save NicolasT/354885 to your computer and use it in GitHub Desktop.
import Control.Arrow
import Data.List
replace_fizzbuzz n = if n `mod` 15 /= 0 then Left n else Right "fizzbuzz"
replace_fizz n = if n `mod` 3 /= 0 then Left n else Right "fizz"
replace_buzz n = if n `mod` 5 /= 0 then Left n else Right "buzz"
fizzbuzz = replace_fizzbuzz >>> (replace_fizz ||| Right) >>>
(replace_fizzbuzz ||| Right) >>> (show ||| returnA)
main = do
putStrLn $ intercalate "\n" [fizzbuzz x | x <- [1..100]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment