Streams and comprehensions
A Stream is a pipeline that has not run yet: it describes the work and waits for a call that wants a result. A comprehension is the same idea written as one for, and a range is the simplest enumerable there is.
The part ends with a file read line by line, which is where a lazy pipeline pays for itself: the program reads what it needs and not the whole file.
6.1
Stream in Elixir
a lazy pipeline, Stream.map and filter, and the work that waits for Enum
Open
6.2
Comprehensions in Elixir
for, its generators, the filters, and the into: that builds a map
Open
6.3
Ranges
a range as an enumerable, first and last, step, and the count that is free
Open
6.4
Streams over files
File.stream!, one line at a time, and a file bigger than memory
Open
6.5
Lazy and eager
what a Stream costs, when Enum is simpler, and an infinite stream that ends
Open
6.6
Comprehensions at work
a generator over a map, two generators, and uniq and sort at the end
Open