Skip to content

Instantly share code, notes, and snippets.

@quanon
Created June 24, 2015 09:50
Show Gist options
  • Save quanon/87d4e6d4686ddcb023bc to your computer and use it in GitHub Desktop.
Save quanon/87d4e6d4686ddcb023bc to your computer and use it in GitHub Desktop.
Elixir で FizzBuzz
calc_rems = fn (n) -> {rem(n, 3), rem(n, 5), n} end
fizzbuzz = fn
{0, 0, _} -> "FizzBuzz"
{0, _, _} -> "Fizz"
{_, 0, _} -> "Buzz"
{_, _, n} -> n
end
IO.inspect(1..50 |> Enum.map(calc_rems) |> Enum.map(fizzbuzz))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment