public function reduce(callable $func, $carry = null)
    {
        foreach ($this->intervals as $offset => $interval) {
            $carry = $func($carry, $interval, $offset);
        }

        return $carry;
    }
public function reduce(callable $func, $carry = null)
    {
        foreach ($this->intervals as $offset => $interval) {
            $carry = $func($carry, $interval, $offset);
        }

        return $carry;
    }
public function reduce ( callable $ func , $ carry = null ) { foreach ( $ this -> intervals as $ offset => $ interval ) { $ carry = $ func ( $ carry , $ interval , $ offset ) ; } return $ carry ; }
Iteratively reduces the sequence to a single value using a callback.

@param callable $func Accepts the carry, the current value and the current offset, and
returns an updated carry value.

@param mixed|null $carry Optional initial carry value.

@return mixed The carry value of the final iteration, or the initial
value if the sequence was empty.
Iteratively reduces the sequence to a single value using a callback .