Added reduce and reduceRight functions.