Created
March 19, 2015 01:10
-
-
Save tsuharesu/8af3e52a81d171d5f05d to your computer and use it in GitHub Desktop.
Fizzbuzz in Elixir
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
# 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