public function reduce(array $array, callable $callback, $initialValue = null)
    {
        if ($initialValue !== null) {
            $accumulator = $initialValue;
        } else {
            $accumulator = array_shift($array);
        }
        foreach ($array as $key => $element) {
            $accumulator = $callback($accumulator, $element, $key);
        }
        return $accumulator;
    }