Understanding Elixir Enum Module

This and the other “Deck” posts are a repurposing of flashcard study decks to Q&A blog posts.

What is an Elixir Enum?

It's a Protocol that defines a set of functions to operate on enumerable data types.

When should you use the Enum module?

When you need to perform an operation against a collection and the collection's type does not implement the function you are looking for, the `Enum` module likely implements it.

What data types is the Enum module implemented for?

`List`, `Map`, `Range`, `MapSet`.

What does it mean to say "functions on the Enum module run in linear time"?

When performing operations Elixir's `Enum` always begings with the first element and ends with the last, the larger the enum is the less efficient the operation will be.

What does the Enum.concat/2 function do?

It combines the first enum argument with the second enum argument.
=> Enum.concat(%{user: "kevs_burgers"}, %{name: "Kevin"})
[user: "kevs_burgers", name: "Kevin"]

What does the Enum.find/2 function do?

It accepts an enumerable and a callback function as arguments. It returns the first element that the function passed to it returns a truthy value for.
=> colors = ["blue", "yellow", "red"] 
=> Enum.find(colors, fn (color) -> color == "red" end) 

What does the Enum.map/2 function do?

It accepts an enumerable and a function as arguments. It returns a new Enum containing the result of the callback function for each element in the Enum.
=> colors = ["blue", "yellow", "red"] 
=> Enum.map(colors, fn (color) -> "#{color}ish" end) 
["blueish", "yellowish", "redish"]