--
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/dc7b3c13-08c7-48e8-a338-fe409ca4202an%40googlegroups.com.
It was pointed out that perhaps we don't do this to express that indexing a list is not fast in Elixir like it is in other languages, but I'm not sure if that is sufficient reason IMO to leave out a typically very standard feature of lists.Thoughts?
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/dc142043-83dc-48e6-8c3f-7a39c8376d0e%40app.fastmail.com.
Languages that support it via square brackets: Rust, Ruby, Javascript, Python, C, Julia.
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/311c75ed-b0fc-4660-945d-b190e294b939%40app.fastmail.com.
Depending on what exactly you are doing, and the size of your lists, it may be worth taking a look at the :array module provided by Erlang. It will give you logarithmic access times, or O(log n). But it still has the downside of not having [] type access.
To add on to that, there are quite a number of excellent
libraries on Hex.pm which provide arrays including support for the
Access behaviour (which gives you `[]`-indexing and a few other
capabilities), such as:
- Aja, which provides
a persistent vector based on RRB trees. In some
benchmarking I did a year ago, Aja turned out to be the
fastest general-purpose array implementation in Elixir.
- Arrays (written by
me), which supports a unified interface to a bunch of different
array implementations (such as map-based arrays and Erlang's
`:array` module).
- Nx, which provides
natively-implemented (one- and multi-dimensional) arrays for
numbers and can potentially run computations with them on your
GPU.
- Explorer, which
provides natively-implemented one-dimensional 'series' and
two-dimensional 'dataframes'.
Those last two do not allow you to store 'all' kinds of Elixir datastructures inside them, but they are often more efficient than a library written in pure Elixir when you have a lot of data or do a lot of calculations.
~Qqwy / Marten
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KaQjO4D%3DJa46z6sOY-Wj9a8cb0%2BB7N%3DUGx5cYjKKGSjw%40mail.gmail.com.
Languages that support it via square brackets: Rust, Ruby, Javascript, Python, C, Julia.All of these languages (other than maybe Julia? I have not used it at all.) are actually using arrays and not lists. It is fairly natural to have easy index based lookup for arrays. After all, it is meant to be a contiguous block of memory with each element having a known size. At least for Rust and C, other languages may be more loose in terms of implementation.
The harm isn't for people who doing it intentionally, the harm is for people who are doing it unintentionally. Index based array access is so common in certain languages that it's one of the first thing newbies from those languages will try in Elixir and if it works then they'll just proceed writing loops like: