Last active
November 4, 2015 04:53
-
-
Save maiah/034b852e084ccf5781ba to your computer and use it in GitHub Desktop.
Enum solution to http://elixirexperience.com/problems/2
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 P2 do | |
def num_to_list(mx) do | |
if mx > 1 do | |
Enum.reduce(1..mx, fn (x, acc) -> "#{acc},#{x}" end) | |
else | |
"#{mx}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment