Skip to content

Instantly share code, notes, and snippets.

@gonzofish
Created April 29, 2017 12:56
Show Gist options
  • Save gonzofish/373e1a43a61c9fca388d1e18e55a76c6 to your computer and use it in GitHub Desktop.
Save gonzofish/373e1a43a61c9fca388d1e18e55a76c6 to your computer and use it in GitHub Desktop.
Solving FizzBuzz without if in Elixir
fizz_word = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, third) -> third
end
fizz_buzz = fn n -> fizz_word.(rem(n, 3), rem(n, 5), n) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment