Last active
January 12, 2016 16:40
-
-
Save rrshaban/050a9336d5989c592249 to your computer and use it in GitHub Desktop.
FizzBuzz in Elixir
This file contains 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
fb_helper = fn | |
(0, 0, _) -> "FizzBuzz" | |
(0, _, _) -> "Fizz" | |
(_, 0, _) -> "Buzz" | |
(_, _, x) -> x | |
end | |
fizz_buzz = fn | |
n -> fb_helper.(rem(n, 3), rem(n, 5), n) | |
end | |
IO.inspect Enum.map(1..100, fizz_buzz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment