Skip to content

Instantly share code, notes, and snippets.

@O-I
Created July 11, 2014 16:35
Show Gist options
  • Save O-I/df5881edd765c9f4f1bc to your computer and use it in GitHub Desktop.
Save O-I/df5881edd765c9f4f1bc to your computer and use it in GitHub Desktop.
FizzBuzz in Haskell
fizzbuzz :: Int -> [String]
fizzbuzz n = take n $ addNums $ zipWith (++) fizz buzz
where fizz = cycle ["", "", "Fizz"]
buzz = cycle ["", "", "", "", "Buzz"]
addNums = zipWith numOrNot $ map show [1..]
numOrNot = \ x y -> if null y then x else y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment