Skip to content

Instantly share code, notes, and snippets.

@maxim maxim/select_at.ex
Created Jun 30, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.