Suppose I have a complicated function function f(A, B)
. I want to recursively apply this to a list of inputs, X = [C, D, E]
.
I would like to know how I can define a function g
so that the output of g([C, D, E])
is f(f(C, D), E)
, for arbitrary lengths of X
.
Let us define an example function:
def f(A, B):
return A + B
How would I define g
?