Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

FizzBuzz

View FizzBuzz.hs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
module Main where
 
import Control.Applicative ((<*>))
import Data.Semigroup ((<>)) -- http://hackage.haskell.org/package/semigroups
import Data.Maybe (fromMaybe, listToMaybe, maybe)
import System.Environment (getArgs)
import Data.Lens.Partial.Common(getorPL, headLens) -- http://hackage.haskell.org/package/data-lens
 
fizzbuzz ::
Integral a =>
a
-> String
fizzbuzz =
let x .| True = Just x
_ .| False = Nothing
s ~> q = (s .|) . (0 ==) . (`rem` q)
in fromMaybe . show <*>
"fizz" ~> 3 <>
"buzz" ~> 5 <>
"bazz" ~> 7
 
main ::
IO ()
main =
do a <- getArgs
let z = fmap fizzbuzz [1..getorPL headLens 100 . fmap read $ a]
mapM_ putStrLn z
Owner

Don't need import Data.Maybe(listToMaybe, maybe)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.