Map, reduce and aggregates
Ranges
Section titled “Ranges”A range is start:end, inclusive at both ends. It is recognised inside brackets
or a function call. A bare 0:3 at the top level is a clock time, because that
reading is far more common in a document.
map(10*x, 0:3) // [0, 10, 20, 30]The implicit variable is x.
map(10*x, [1,2,3]) // [10, 20, 30]Reduce
Section titled “Reduce”The implicit variables are acc for the accumulator and x for the element.
reduce(acc+x, [1,2,3]) // 6Sum and product
Section titled “Sum and product”Shorthand for the two most common reductions.
sum(x, [10, 20, 30]) // 60prod(x, [2,3,4]) // 24sum(x, 0:4) // 10