Reputation: 918
Is there a reason to use enum library over erlang lists when writing code in Elixir? lists has many of the same functions, like takewhile, partition, any, all...
also elixir-lang.org states "Elixir provides excellent interoperability with Erlang libraries. In fact, Elixir discourages simply wrapping Erlang libraries in favor of directly interfacing with Erlang code."
Is it because the condition function needs to be formated differently that Enum is used over Lists?
Upvotes: 1
Views: 978
Reputation: 136
So, Enum
is a module that holds functions that work with data structures implementing the Enumerable
protocol.
Lists in Erlang/Elixir are Linked Lists, which have several properties in terms of algorithmic complexity when it comes to indexing and inserting.
Enumerables in Elixir are data structures such as lists, but also maps and mapsets. However, as stated in the documentation:
the majority of the functions in Enum enumerate the whole enumerable and return a list as result
That being said, two reasons to use Enum
functions over List
-based functions is that basically:
Upvotes: 4