Last active
August 29, 2015 14:16
-
-
Save plukevdh/6e95765b65c94f9c07f7 to your computer and use it in GitHub Desktop.
Fizz Buzz
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
defmodule Streem do | |
def fb(n) when rem(n,15) == 0, do: "FizzBuzz" | |
def fb(n) when rem(n,3) == 0, do: "Fizz" | |
def fb(n) when rem(n,5) == 0, do: "Buzz" | |
def fb(n), do: n | |
end |
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
defmodule Streem do | |
def fb(n) do | |
case n do | |
n when rem(n, 15) == 0 -> "FizzBuzz" | |
n when rem(n, 3) == 0 -> "Fizz" | |
n when rem(n, 5) == 0 -> "Buzz" | |
_ -> n | |
end | |
end | |
end | |
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
0..1000 | |
|> Enum.map &(Streem.fb(&1)) | |
|> IO.puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment