Whatever message this page gives is out now! Go check it out!
ListReduce(list, callback, initialValue, [delimiter, includeEmptyFields])Parameter | Req/Opt | Default | Description |
| list | Required | The input list. | |
| callback | Required | Closure or a function reference that will be called for each iteration. The arguments passed to the callback are
| |
| initialValue | Optional | Initial value which will be used for the reduce operation. The type is any. | |
| delimiter | Optional | comma (,) | The list delimiter. The type is string . |
| includeEmptyFields | Optional | false | Include empty values. The type is boolean. |
<cfscript>
myList="23,54,87,98,11,35,91";
closure=function(value1,value2){
return (value1+value2/ListLen(myList)); // Calculates the average of the values in the list
}
MyVal=ListReduce(myList,closure,0); // Initial value is 0
WriteOutput(#myVal#);
</cfscript>