closest thing to arrays in Elixir
I ended up using a combination of list
and registry
since I was working with processes. I got many responses on Elixir forum which I'm listing below for future reference:
Tuple
: stored continuous in memory, constant access time, editing results in copying whole structure. Does not implement Enumerable protocol.- linked-
List
: O(n) access time, prefixing is cheaper than suffixing. Implements Enumerable protocol. Map
: O(log n) read, write, delete time. Also implements Enumerable protocol.:array
:array
module from Erlang.registry
: (applicable only if storing processes) A local, decentralized and scalable key-value process storage.
Also, note 2 and 3 (List and Map) are persistent data structures.
There are also two Elixir packages Arrays and Tensor that provide similar functionalities.