Skip to content

Instantly share code, notes, and snippets.

@TGOlson
Created March 8, 2015 08:14
Show Gist options
  • Select an option

  • Save TGOlson/c770f10fc9f07cae1fb2 to your computer and use it in GitHub Desktop.

Select an option

Save TGOlson/c770f10fc9f07cae1fb2 to your computer and use it in GitHub Desktop.
Haskell FizzBuzz Kata
getFizzBuzz :: (Int, Int, Int) -> String
getFizzBuzz (_, 0, 0) = "FizzBuzz"
getFizzBuzz (_, 0, _) = "Fizz"
getFizzBuzz (_, _, 0) = "Buzz"
getFizzBuzz (x, _, _) = show x
fizzBuzz :: Int -> [String]
fizzBuzz n = [getFizzBuzz (x, x `mod` 3, x `mod` 5) | x <- [1..n]]
fizzBuzz 15
["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
@mijinrocks
Copy link

map _ [] = []
map f x:xs = (f x):(map f xs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment