Revision 678f22058e870d1a1447738460a218f1866d7df6 authored by TUNA Caglayan on 19 May 2021, 14:13:39 UTC, committed by TUNA Caglayan on 08 October 2021, 13:05:18 UTC
1 parent a5bc403
_prod.py
from functools import reduce
def _prod(array_like):
"""Calculate the product of all the elements in the input iterable. The default start value for the product is 1.
When the iterable is empty, return the start value.
Parameters
----------
array_like : list-like object
Returns
-------
equivalent of math.prod(array_like)
"""
return reduce(lambda x, y: x*y, array_like, 1)
try:
from math import prod
except ImportError:
prod = _prod
Computing file changes ...