Reduce function with add : reduce « Buildin Function « Python






Reduce function with add

Reduce function with add
import operator
print reduce(operator.add, [2, 4, 6])      # function-based +

print reduce((lambda x, y: x + y), [2, 4, 6])




           
       








Related examples in the same category

1.Reduce: lambda function insideReduce: lambda function inside
2.Functional Programming Tools: reduceFunctional Programming Tools: reduce
3.Functional Programming Tools: reduce 2Functional Programming Tools: reduce 2