Hey Anton, I hadn't tried a FizzBuzz in Elixir yet, so I took a stab at it:
defmodule FizzBuzz do
def run(n) when is_integer(n), do: do_fizzbuzz(n)
defguardp divisible_by_3(n) when rem(n, 3) === 0
defguardp divisible_by_5(n) when rem(n, 5) === 0
defp do_fizzbuzz(n) when divisible_by_3(n) and divisible_by_5(n), do: "FizzBuzz"
defp do_fizzbuzz(n) when divisible_by_3(n), do: "Fizz"
defp do_fizzbuzz(n) when divisible_by_5(n), do: "Buzz"
end
Hey Anton, I hadn't tried a FizzBuzz in Elixir yet, so I took a stab at it:
Interesting : )