add an optimized implementation for Array#reduce()