Skip to content

Instantly share code, notes, and snippets.

@kcurtin
Last active December 26, 2015 15:53
Show Gist options
  • Save kcurtin/e129758fcb7270ff9163 to your computer and use it in GitHub Desktop.
Save kcurtin/e129758fcb7270ff9163 to your computer and use it in GitHub Desktop.
Fizzbuzz in elixir using pattern matching
Enum.each 1..100, fn (n) ->
fizzbuzz = fn
(0, 0, _) -> "fizzbuzz"
(0, _, _) -> "fizz"
(_, 0, _) -> "buzz"
(_, _, n) -> n
end
IO.puts fizzbuzz.(rem(n, 3), rem(n, 5), n)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment