Skip to content

Instantly share code, notes, and snippets.

@srbaker
Last active August 29, 2015 14:01
Show Gist options
  • Save srbaker/b82ff8f170f1c71f30e9 to your computer and use it in GitHub Desktop.
Save srbaker/b82ff8f170f1c71f30e9 to your computer and use it in GitHub Desktop.
Fizz Buzz in Haskell
-- Feels like there's a shorthand for the duplicated `mod` expressions.
fizzBuzz x
| (x `mod` 3) == 0 && (x `mod` 5) == 0 = "FizzBuzz"
| (x `mod` 3) == 0 = "Fizz"
| (x `mod` 5) == 0 = "Buzz"
| otherwise = show x
-- Extracting the mod expressions in any way I know how (so far) leads to more complication.
@jbrains
Copy link

jbrains commented May 7, 2014

Guard Clauses depend on sequence. Always has been; always will be.

@jbrains
Copy link

jbrains commented May 7, 2014

I think this is about as good as mine's going to get: https://gist.github.com/jbrains/2a29465457bddcca0c45

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