Created
November 14, 2014 23:01
-
-
Save csarcom/2b8a63b64729660eb7d4 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
lista = [1,2,3,3,4] | |
defmodule Misc do | |
def dup([]) do | |
{:done, nil} | |
end | |
def dup(list) do | |
_dup(list, []) | |
end | |
def _dup([], result) do | |
result | |
end | |
def _dup([head | tail], list) do | |
result = tail -- [head] | |
_dup(result, list ++ [head]) | |
end | |
end | |
Misc.dup(lista) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment