Skip to content

Instantly share code, notes, and snippets.

@maxim
Created June 30, 2017 08:09
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 maxim/bc62140861ce623ec3fb0ee1c6fa175f to your computer and use it in GitHub Desktop.
Save maxim/bc62140861ce623ec3fb0ee1c6fa175f to your computer and use it in GitHub Desktop.
def select_at(list, indexes),
do: select_at(list, indexes, 0, []) |> Enum.reverse
def select_at([], _, _, results),
do: results
def select_at(_, [], _, results),
do: results
def select_at([item | list], [i | indexes], i, results),
do: select_at(list, indexes, i + 1, [item | results])
def select_at([_ | list], indexes = [index | _], i, results),
do: select_at(list, indexes, i + 1, results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment