Skip to content

Instantly share code, notes, and snippets.

@brweber2
Created April 27, 2016 17:04
Show Gist options
  • Save brweber2/426512c59fb12efbbcae81fc5576650c to your computer and use it in GitHub Desktop.
Save brweber2/426512c59fb12efbbcae81fc5576650c to your computer and use it in GitHub Desktop.
def ex2(characters, type), do: ex2h(characters, type, [])
def ex2h([head = %{type: type} | tail], type, result) do
ex2h(tail, type, [head | result])
end
def ex2h([head | tail], type, result), do: ex2h(tail, type, result)
def ex2h([], _type, result), do: Enum.reverse(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment