Lists
- There are useful λ-calculus functions that are commonly defined on lists, e.g.,
- append L1 L2 — if list L1 is empty return L2,
otherwise the result is the first element of L1
(i.e., hd L1) followed by the result of appending the tail of
L1 and all of L2 (i.e., append tl L1) L2),
- foldL f z L — f(...(f (f z L1) L2)... Ln,
- foldR f z L — f L1 (d L2 (... (f Ln z)...)),
- map f L — apply function f to each element of list L, returning a new list,
- merge L1 L2 — merge two sorted lists,
- reverse L — return a reversed version of a list,
- take n L — return the first n elements of the list L,
- zip L1 L2 — takes a pair of lists and returns a list of pairs,
- foldL f z L — f(...(f (f z L1) L2)... Ln,
- and many more.
There are more λ-calculus examples here.