Sum

Arithmetic sum

Signature

sum(expr: AttrName|(Tuple->Numeric)) -> Aggregator

Examples

sum(:qty)
sum{|t| t.qty * t.price }
sum(->(t){ t.qty * t.price })

Description

Computes v1 + v2 + ... + vn.

Implementation notes

This aggregate function should only be used with numeric types. As of current Alf version, it does not aggregate empty sets correctly on non-numeric data types.