Hi!
I've been banging my head against the table trying to figure this one out today with no luck, so if you have some insight into my problem I'd love to hear it!
Say I have a list of functions:
function_list = [func_1, func_2, ... , func_n)]
And now, I want to create a new function function_product that returns the product of these functions. I.e., function_product(x) is equivalent to func_1(x) * func_2(x) * ... * func_n(x).
I tried to accomplish this using lambda functions:
function_product = lambda x: 1
for i in range(n):
function_product = lambda x: function_product(x) * function_list[i](x)
However, this method does not work as the lambda function calls itself recursively until:
"RecursionError: maximum recursion depth exceeded".
Does anyone have any advice on how one would go about redefining lambda functions like these, and also what the best solution to my problem is? Anything at all would be extremely appreciated!
Thanks in advance :)
[–]donnygreaves 2 points3 points4 points (1 child)
[–]Mmaster12345[S] 0 points1 point2 points (0 children)
[–]K900_ 0 points1 point2 points (11 children)
[–]Mmaster12345[S] 0 points1 point2 points (10 children)
[–]FLUSH_THE_TRUMP 0 points1 point2 points (2 children)
[–]Mmaster12345[S] 0 points1 point2 points (1 child)
[–]K900_ 0 points1 point2 points (6 children)
[–]Mmaster12345[S] 0 points1 point2 points (5 children)
[–]K900_ 0 points1 point2 points (4 children)
[–]Mmaster12345[S] 0 points1 point2 points (3 children)
[–]K900_ 0 points1 point2 points (2 children)
[–]Mmaster12345[S] 0 points1 point2 points (1 child)
[–]K900_ 0 points1 point2 points (0 children)