Skip to content

Instantly share code, notes, and snippets.

@sardaukar
Forked from gonzofish/fizz_buzz.exs
Created May 4, 2017 09:23
Show Gist options
  • Save sardaukar/0ee9349f4b34d52bf96499b945afc201 to your computer and use it in GitHub Desktop.
Save sardaukar/0ee9349f4b34d52bf96499b945afc201 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