June 18, 2022
I have been struggling learning the lambda function using recursion, I think I’m ok with the basic lambda, I think the major milestone here is the ability to call itself!!!!, I was trying to follow up the "factorial exercise video" and I try to do a very simple one to see if I got it but it has been impossible for me to figure out what I’m doing wrong here…..
My simple example where I’m trying to find a number x (variable) to make the difference between the target and calculated value zero (kind of goal seek basic example), you can see also the formulae I’m using….. any idea of what my mistake is?
newvalue = lambda (target, calc, x, if (target = calc, x, x + newvalue (target, calc, x + target - calc))))
Calc 3 (variable + constant)
Using newvalue lambda function I hope to get as result 5 (4 is the difference between Target and Calc that should be added to variable to arrive to the final value of 5)
Any idea what am I doing wrong here?
January 31, 2022
Perhaps I haven't fully understood your intentions but based on what you described in your example I believe such a recursive LAMBDA function (named "jose") could be like this:
=LAMBDA(c, v, t,
c + v = t,
jose(c, v + 1, t)
where c, v and t refer to Constant, Variable an Target respectively. Note that the Calculation is not one of the function arguments, but it's done inside the IF statement.