The main reason for an index function is to make it easier to build a map:

    Map.new Enum.index(data)

I agree the duplicity between noun and verb is undesirable though.

On Tue, Dec 8, 2020 at 9:52 PM Kelvin Raffael Stinghen <
kelvin.sting...@gmail.com> wrote:

> I can't see why not just `x |> Stream.with_index() |> Stream.map(fn {v, i}
> -> {i, v} end)`... I mean, lots of proposals for similar functions got
> denied because it would be easy to develop a lib that does it cause Elixir
> is awesomely extensible, so why bothering add another variant? Do you have
> to do that too many times on Elixir core or something like that?
>
> Em terça-feira, 8 de dezembro de 2020 às 17:44:45 UTC-3, gva...@gmail.com
> escreveu:
>
>> If this is related to the mystery benchmark tweets, José, then I guess
>> I'm in favor of the proposal :-)
>>
>> I do prefer Felipe's name of `Enum.indexed/1` though. While `index` can
>> be a verb, it's ambiguous with the noun. `indexed` is clearly a past tense
>> verb.
>>
>> -Greg Vaughn
>>
>> > On Dec 8, 2020, at 2:13 PM, José Valim <jose....@dashbit.co> wrote:
>> >
>> > I considered the option but I prefer to avoid using options that change
>> the return type.
>> >
>> > On Tue, Dec 8, 2020 at 9:11 PM Felipe Stival <v0i...@gmail.com> wrote:
>> > I'm not sure. Sounds a bit ambiguous, couldn't this be an option for a
>> new Enum.with_index/3?
>> >
>> > Em ter., 8 de dez. de 2020 às 17:05, José Valim <jose....@dashbit.co>
>> escreveu:
>> > 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 elixir-lang-co...@googlegroups.com.
>> > 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.
>>
>> >
>> >
>> > --
>> >
>> > Felipe Stival, Electrical Engineering Student
>> > Santa Maria, Rio Grande do Sul
>> > Brasil
>> > v0idpwn.github.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 elixir-lang-co...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/CAKC64%2Bx4zERK_axkS2puMT9Qa8dJKYEh_Z3QNDf977eJG0-6aw%40mail.gmail.com.
>>
>> >
>> > --
>> > 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 elixir-lang-co...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Kj%3DS54yn-1jmoaG%2BKEab9ZLpagHYDfpNEu%2BSbtTdj%2B4g%40mail.gmail.com.
>>
>>
>> --
> 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 elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/84a8a35f-13b7-4b83-95b5-2c414df6cc04n%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/84a8a35f-13b7-4b83-95b5-2c414df6cc04n%40googlegroups.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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LVZ%2BDSd3tuUe-Y0Rczn1p8aL69-mDYNVYtoBy_P%3D6kRA%40mail.gmail.com.

Reply via email to