Iteratively reduce the array to a single value using a callback function