Steve's Roc Apps roc-apps on GitHub

Safari Ride Chapters

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_with_index 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_oks Calls a function that returns a Try on each item, keeps the Ok values, and drops the Errs Errors as tag unions
List.from_iter Collects a count, such as U32.until(0, n), into a list The road
join_map Maps each item to a list, and joins the lists into one Rails
drop_first 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_first Returns the first item that passes a test, as a Try The truck's motion
List.repeat Makes a list of one value, as many times as it's given The cat
take_first 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