Current section

Files

Jump to
elixir_prelude lib prelude list.ex
Raw

lib/prelude/list.ex

defmodule Prelude.List do
@moduledoc "Functions operating on `lists`."
@doc "Turns an array into a map with the index as the key."
def indexify(list) when is_list(list) do
list
|> Enum.with_index
|> Enum.map(fn {k, v} -> {v, k} end)
|> Enum.into(%{})
end
end