ProgrammingElixir1.6-MyTurns/Functions-2.exs

15 lines
507 B
Elixir
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Write 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. Do not use any language features that we havent yet covered in this book.
fun = fn
{0, 0, _} -> "FizzBuzz"
{0, _, _} -> "Fizz"
{_, 0, _} -> "Buzz"
{_, _, c} -> c
end
IO.puts fun.({0, 0, 1})
IO.puts fun.({0, 1, 1})
IO.puts fun.({1, 0, 1})
IO.puts fun.({1, 1, 1})