Appendix: list functions
The ride builds most of its answers out of lists. These are the main List functions the chapters use, in the order they first come up.
| Function | What it does | Chapter |
|---|---|---|
map |
Calls a function on each item, and returns a list of the answers | Lists and map: a far tree |
map_ |
map, with each item's place in the list, counting from 0 |
Lists and map: a far tree |
concat |
Puts a second list after the first | Lists and map: a far tree |
join |
Makes one list of a list of lists | The pipeline |
keep_ |
Calls a function that returns a Try on each item, keeps the Ok values, and drops the Errs |
Errors as tag unions |
List. |
Collects a count, such as U32., into a list |
The road |
join_ |
Maps each item to a list, and joins the lists into one | Rails |
drop_ |
Drops the first items, as many as it's given | Rails |
fold |
Hands each item in turn to a function, along with the answer so far, starting from a first answer | The throttle |
find_ |
Returns the first item that passes a test, as a Try |
The truck's motion |
List. |
Makes a list of one value, as many times as it's given | The cat |
take_ |
Keeps the first items, as many as it's given | The math layer |
map2 |
Walks two lists side by side, and calls a function on each pair | The math layer |