Skip to content

Instantly share code, notes, and snippets.

@tsuharesu
Created March 19, 2015 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsuharesu/8af3e52a81d171d5f05d to your computer and use it in GitHub Desktop.
Save tsuharesu/8af3e52a81d171d5f05d to your computer and use it in GitHub Desktop.
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