CollectionReduce()
Iterates over every entry of the collection and calls the closure with every element. This function will reduce the array to a single value and will return the value.
CollectionReduce( collection=object, closure=function, initialValue=object );
Returns: any
Examples
thresholds = [1, 3, 4, 5];
score = CollectionReduce(thresholds, function(a, b) {
return a + b^2;
}, 0);
dump(score); // 51
score = thresholds.reduce(function(a, b) {
return a + b^2;
}, 0);
dump(score); // 51
See also
- Collections
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)