2.9 Common idioms: map, filter, foldl' and friends
Lesson 16 of 68 · 11:39
Up next in 5s…
About this lesson
You could write every list operation recursively by hand, but you should not have to. This lesson introduces map, filter and foldl', the everyday idioms of functional programming in Nix, and shows where the huge nixpkgs standard library documents hundreds more.
In this video
builtins.filterandmapin the REPL, plus a first taste of eta reduction- The
sumfunction from the exercise, rewritten in one line withfoldl' - Why Nix has three manuals, and which one to open for what
- noogle.dev, a search engine for Nix functions, with examples and links straight into the nixpkgs source
- The three library files that hold about 80 percent of the functions you will ever need
After this lesson
You stop reinventing the wheel: before writing a helper yourself, you know exactly where to check whether nixpkgs already ships it.
Builds on: Exercise: sum a list with recursion (2.13)
Links: