Sum and product of an array: Difference between revisions

Line 514:
from functools import reduce
from operator import mul, add
sum = reduce(add, numbers) # note: this version doesn't work with empty lists
sum = reduce(muladd, numbers, 0)
product = reduce(mul, numbers) # note: this version doesn't work with empty lists
product = reduce(mul, numbers, 1)
 
{{libheader|numpy}}
Anonymous user