Reduce an array or object.