There is a bit of a collision with the option for the offset, but you could pattern match that.
-bt On Tue, Dec 8, 2020 at 4:57 PM Zach Daniel <[email protected]> wrote: > I like that idea a lot Bruce. Let’s you do something like: > > maps |> Enum.with_index(&Map.put(&1, :index, &2)) > > On Tue, Dec 8, 2020 at 4:50 PM Bruce Tate <[email protected]> wrote: > >> Maybe a transform function on with_index? >> >> Enum.with_index([:a, :b, :c], &{&2, &1}) >> >> -bt >> >> On Tue, Dec 8, 2020 at 3:05 PM José Valim <[email protected]> wrote: >> >>> I would like to propose an Enum.index/2 function. It behaves like >>> with_index/2 but the index is the first argument: >>> >>> iex> Enum.index([:a, :b, :c]) >>> [{0, :a}, {1, :b}, {2, :c}] >>> >>> I am hoping it reads "index" this tuple (hence the index as the first >>> element. While with_index means attach an index information to each element >>> (hence the second element). Is this sound? >>> >>> Thank you, >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K6h7c1UbiEfoEsyCXGJRbO8he%3DFJ84yxC%2B3-GOo-2MwQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K6h7c1UbiEfoEsyCXGJRbO8he%3DFJ84yxC%2B3-GOo-2MwQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> >> Regards, >> Bruce Tate >> CEO >> >> >> <https://bowtie.mailbutler.io/tracking/hit/f8218219-d2a8-4de4-9fef-1cdde6e723f6/c7c97460-016e-45fb-a4ab-0a70318c7b97> >> >> Groxio, LLC. >> 512.799.9366 >> [email protected] >> grox.io >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elixir-lang-core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4QOLzA4h34KBVSF1OnMFzxJZEwReV334YP3Pwu7cYX1g%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4QOLzA4h34KBVSF1OnMFzxJZEwReV334YP3Pwu7cYX1g%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAK-yb0AY9GhKiZJ9GS78%2BW3z5m3%3Ds-F%2BNrQiUYje2WOT%3D65ScA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAK-yb0AY9GhKiZJ9GS78%2BW3z5m3%3Ds-F%2BNrQiUYje2WOT%3D65ScA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Regards, Bruce Tate CEO <https://bowtie.mailbutler.io/tracking/hit/f8218219-d2a8-4de4-9fef-1cdde6e723f6/c7c97460-016e-45fb-a4ab-0a70318c7b97> Groxio, LLC. 512.799.9366 [email protected] grox.io -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4Qnfiy_R6UT7yhGhgezrTXwXwapHXMbW4-gJwMjiMQ6g%40mail.gmail.com.
