Created
May 5, 2015 18:48
-
-
Save trevrosen/32635216d03ab96e5593 to your computer and use it in GitHub Desktop.
Elixir Fizzbuzz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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