Skip to content

Instantly share code, notes, and snippets.

@rin
Created August 21, 2013 13:01
Show Gist options
  • Save rin/6294171 to your computer and use it in GitHub Desktop.
Save rin/6294171 to your computer and use it in GitHub Desktop.
Yet Another FizzBuzz in Elixir.
defmodule FizzBuzz do
def fizzbuzz(n) do
fizz_or_buzz = fn
[0, 0, _] -> :fizzbuzz
[0, _, _] -> :fizz
[_, 0, _] -> :buzz
[_, _, n] -> n
end
fizz_or_buzz.([rem(n, 3), rem(n, 5), n])
end
def list(upper_limit // 100) do
Enum.each (0..upper_limit), fn(x) ->
IO.puts "#{x}: #{fizzbuzz(x)}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment