Last active
December 31, 2015 01:38
-
-
Save st23am/7914932 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
#FizzBuzz with module, named functions, and no conditional | |
defmodule Kata do | |
def fizzbuzz( 0, 0, _ ), do: "FizzBuzz" | |
def fizzbuzz( 0, _, _ ), do: "Fizz" | |
def fizzbuzz( _, 0, _ ), do: "Buzz" | |
def fizzbuzz( _, _, x ), do: "#{ x }" | |
def fizzbuzz(n) do | |
fizzbuzz(rem(n, 3), rem(n, 5), n) | |
end | |
end | |
Enum.map(1..100, &(IO.puts Kata.fizzbuzz(&1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment