Revision c6d4fdb44a004f804c489c8cb1739ba17d0b0939 authored by TUNA Caglayan on 20 October 2021, 10:09:49 UTC, committed by TUNA Caglayan on 20 October 2021, 10:09:49 UTC
1 parent 2b16764
_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 ...