Skip to content

Instantly share code, notes, and snippets.

@trevrosen
Created May 5, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trevrosen/32635216d03ab96e5593 to your computer and use it in GitHub Desktop.
Save trevrosen/32635216d03ab96e5593 to your computer and use it in GitHub Desktop.
Elixir Fizzbuzz
# From Dave Thomas' Elixir book:
# https://pragprog.com/book/elixir/programming-elixir
fizzbuzz = fn
0,0,_ -> "FizzBuzz"
0,_,_ -> "Fizz"
_,0,_ -> "Buzz"
_,_,n -> n
end
#IO.puts fizzbuzz.(0,0,1)
#IO.puts fizzbuzz.(0,1,1)
#IO.puts fizzbuzz.(1,2,3)
fuzzcheck = fn
n -> fizzbuzz.(rem(n,3), rem(n, 5), n)
end
IO.puts fuzzcheck.(10)
IO.puts fuzzcheck.(11)
IO.puts fuzzcheck.(12)
IO.puts fuzzcheck.(13)
IO.puts fuzzcheck.(14)
IO.puts fuzzcheck.(15)
IO.puts fuzzcheck.(16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment