cumsum function Summarizing data
Returns the cumsum of all values in the iterable
.
This function ignores values that do not satisfy any of the following conditions:
- The value is not
null
. - The value is not double.nan.
Useful for filtering and ignoring missing data in datasets.
Implementation
List<num?> cumsum(Iterable<num?> iterable) {
num sum = 0;
return List.generate(iterable.length, (i) {
var v = iterable.elementAt(i);
return v != null && !v.isNaN ? sum += v : sum;
});
}