November 2017
Intermediate to advanced
670 pages
17h 35m
English
Consider the following operation:
1 + 2 + 3 ⇒ [1,2,3] |> List.reduce(+)
Instead of having to write all that code where we type a number, type a +, type another number, and we can feed a list of numbers into our reduce function that applies the + operation to each item and accumulates the sum.
Here's an example of appending strings:
"a" + "b" + "c" ⇒ ["a", "b", "c] |> List.reduce(+)
What was the neutral/identity element used in each of the preceding examples?