Returns the result of combining the elements of collection and initial-value according to function.
If collection is empty, reduce returns initial-value; otherwise, function is applied to initial-value and the first element of collection to produce a new value. If more elements remain in the collection, then function is called again, this time with the value from the previous application and the next element from collection. This process continues until all elements of collection have been processed.
function is a binary function used to combine all the elements of collection into a single value. Processing is always done in the natural order for collection.
define variable high-score = 10
reduce (max, high-score, #(3, 1, 4, 1, 5, 9))
⇒ 10
reduce (max, high-score, #(3, 12, 9, 8, 8, 6))
⇒ 12
open
| function | An instance of <function>. |
| initial-value | An instance of <object>. |
| collection | An instance of <collection>. |
| value | An instance of <object>. |