Skip to content

Instantly share code, notes, and snippets.

@sescobb27
Created August 28, 2018 12:54
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 sescobb27/1f642304c61cad1857602c2d070cf6b5 to your computer and use it in GitHub Desktop.
Save sescobb27/1f642304c61cad1857602c2d070cf6b5 to your computer and use it in GitHub Desktop.
defmodule MyList
def delete_all(list, el) do
_delete_all(list, el, [])
|> Enum.reverse()
end
def _delete_all([el | tail], el, new_list) do
_delete_all(tail, el, new_list)
end
def _delete_all([head | tail], el, new_list) do
_delete_all(tail, el, [head | new_list])
end
def _delete_all([], el, new_list) do
new_list
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment