I am used to the FP/haskell-like concept of reduce, already implemented as a built-in library in Python:
from functools import reduce
lst = [1,2,3,4,5]
reduce(lambda x, y: x*y, lst)
# result: 120
However this doesn't work for, e.g., a lambda with three arguments:
from functools import reduce
lst = [1,2,3,4,5]
reduce(lambda x, y, z: x*y+z, lst)
# expected result: (1*2+3) * 4 + 5
# actual result:
# TypeError: <lambda>() missing 1 required positional argument: 'z'
The rationale is to keep the rule "the previous result is the next first argument".
Is there a built-in implementation, or clever/simple combination of functional constructs to achieve such goal?
ps. Beware of pseudo-duplicates