Lists, Tuples and Maps
- Lists. A list is a linked sequence: [head | tail]: matched and built with the same syntax.
- Tuples. A tuple groups fixed fields: {:ok, value} and {:error, reason} are the return handshake.
- Maps. A map holds key-value data: %{name: "Ada"}: matched with %{name: name} on known keys.
Enum
- Enum module. Enum is the collection workhorse: map, filter, reduce, group_by over anything enumerable.
- Eager evaluation. Enum is eager: each step materialises its result before the next begins.
- Comprehensions. A for comprehension filters, maps and collects: generators and filters in one form.
Streams
- Stream module. Stream is Enum’s lazy twin: steps composed as recipes, run only when demanded.
- Large data. Streams process files of any size in constant memory: one line at a time through the pipeline.
- Choosing Enum or Stream. Small data stays eager; huge or infinite data goes lazy: measured, not guessed.
Before and after this level
- Before: Level 1: Elixir Foundations: Values and Immutability, Pattern Matching, Functions and Modules.
- Next: Level 3: Functional Design: Pipelines, Higher-Order Functions, Recursion and Transformation.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Elixir Level 2: Collections cover?
Lists, Tuples and Maps, Enum, Streams: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 1: Elixir Foundations, which covers Values and Immutability, Pattern Matching, Functions and Modules.