Skip to content

Map, reduce and aggregates

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]

The implicit variables are acc for the accumulator and x for the element.

reduce(acc+x, [1,2,3]) // 6

Shorthand for the two most common reductions.

sum(x, [10, 20, 30]) // 60
prod(x, [2,3,4]) // 24
sum(x, 0:4) // 10