Created
September 24, 2016 21:27
-
-
Save alec-c4/4e146a7d9a5d363c958252ff209917e6 to your computer and use it in GitHub Desktop.
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
defmodule Pin do | |
def generate(length \\ 4) when is_integer(length) and length >= 0 do | |
Enum.join(gen_pin(length)) | |
end | |
defp gen_pin(1) do | |
[:rand.uniform(9)] | |
end | |
defp gen_pin(length) do | |
gen_pin(length - 1) ++ [:rand.uniform(9)] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment