Suppose I have the following list: A = [1,2,3,4], By using the reduce function, to find the product of the elements, I could do
prodA = reduce(lambda x,y: x*y, A)
However, if I have another list B=[9,8,7,6], is it still possible for me to use the reduce function to execute the following action? (from top to the bottom indicate the steps)
9
(9+1)* 2
((9+1) *2)+8
(((9+1) *2)+8)*3
((((9+1) *2)+8)*3)+7
(((((9+1) *2)+8)*3)+7)*4
((((((9+1) *2)+8)*3)+7)*4)+6
I'm not pretty sure if I could add something like an iterator for the list B to the reduce function. How I can do that? Thanks a lot!