Two equivalent functions. You could pass the reduction function as a template or function parameter.