Created
June 5, 2019 03:26
-
-
Save alecho/2c4bb244dbdcfe7644aa0c6db7454b13 to your computer and use it in GitHub Desktop.
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 NaturalNums do | |
import Enum | |
import List | |
def print(n) when not is_integer(n), do: {:error, "input must be an integer"} | |
def print(n) when n < 1, do: {:error, "integer must be positive"} | |
def print(n) do | |
1..n | |
|> map(&IO.puts/1) | |
#For same return value as original | |
|> uniq | |
|> first | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment