Skip to content

Instantly share code, notes, and snippets.

@alecho
Created June 5, 2019 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alecho/2c4bb244dbdcfe7644aa0c6db7454b13 to your computer and use it in GitHub Desktop.
Save alecho/2c4bb244dbdcfe7644aa0c6db7454b13 to your computer and use it in GitHub Desktop.
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