sum function

floatstring sum(array)

array float[]bool[]string[]

Returns one of the following:

The sum of all elements in a float array.
sum([1,2,3])               // 6
The count of all true elements in a bool array.
sum([true,false,true])     // 2
The concatenation of all elements in a string array.
sum(["a","b","c"])         // "abc"

Related

Examples

Count and measure geometric properties

frontLength = sum( comp(fe) { street.front : scope.sx } )

numberSmallFaces = sum( comp(f) { all : geometry.area < 0.1 } )

Cumulative sum

const x = cumsum([1:5])                        // [1,3,6,10,15]
const y = cumsum(["a","b","c","d","e"])        // [a,ab,abc,abcd,abcde]
const z = cumsum([false,true,true,false,true]) // [0,1,2,2,3]

cumsum(array) = case size(array) < 2 : [ sum(array) ]
                else : [ cumsum(array[0:size(array)-2]), sum(array) ]