Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fizzbuzz in Elixir
# This is a exercise in Programming Elixir from Pragmatic Bookshelf
fizzbuzz_check = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, c) -> c
end
fizzbuzz = fn(n) -> fizzbuzz_check.(rem(n, 3), rem(n, 5), n) end
Enum.map 1..100, fn(i) -> IO.puts(fizzbuzz.(i)) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment