Skip to content

Instantly share code, notes, and snippets.

@gouf
Created March 7, 2014 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gouf/9415629 to your computer and use it in GitHub Desktop.
Save gouf/9415629 to your computer and use it in GitHub Desktop.
toStr :: Int -> String
toStr x = if x `mod` 15 == 0 then "FizzBuzz"
else if x `mod` 3 == 0 then "Fizz"
else if x `mod` 5 == 0 then "Buzz"
else show x
fizzbuzz :: Int -> [String]
fizzbuzz n = map toStr[1 .. n]
main = do
print (fizzbuzz 15)
-- output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment