Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Last active August 10, 2016 06:43
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 ivancorrales/d4885aec095d18fc80effa97bbecc09b to your computer and use it in GitHub Desktop.
Save ivancorrales/d4885aec095d18fc80effa97bbecc09b to your computer and use it in GitHub Desktop.
Implement a function that takes three arguments. If the first two are zero, return “FizzBuzz.” If the first is zero, return “Fizz.” If the second is zero, return “Buzz.” Otherwise return the third argument.
test_fn = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, c) -> c
end
IO.puts test_fn.(0,0,1)
IO.puts test_fn.(0,1,1)
IO.puts test_fn.(1,0,1)
IO.puts test_fn.(2,3,4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment