
Functional programming is all about transforming data and if we're going to work with Solar Flares, we need to understand how Lists work - how we query, slice, dice, add and remove. That's what we're going to do now.
Four Important Friends
There are three Elixir modules that you'll use most often when working with lists of data: Enum, List and Keyword:
Enumdoes enumeration functions. Mapping data, filtering, finding, grouping... things like that. This module is absolutely fundamental; get to know it!Listhandles list-specific operations whereasEnumwill work with anything that you iterate over (or that is enumerable). Inserting, deleting, first and last - theListmodule is another that you'll want to know well.- As you might suspect,
Keyworddoes a lot of whatListdoes, but for keyword lists.
In addition to these, Elixir supports list comprehensions. This is syntactic sugar for iterating over enumerable structures, but comes with built-in filters and the unique ability to have more than one generator. We'll get to these last - they can be quite complicated.