Iterates over each item of the list and calls the closure to work on the item. This function will reduce the list to a single value and will return the value.
listReduce(list, function(result, item [,index, list]) [,initialValue, delimiter, includeEmptyFields])
→ returns any
comma
false
numbers = "1,2,3,4,5,6,7,8,9,10";
sum = listReduce(numbers, function(previousValue, value)
{
return previousValue + value;
}, 0);
writeOutput("The sum of the digits #numbers# is #sum#<br>");
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.