Forum Discussion
Legacy EVALUATE in LAMBDA: Build/Test LAMBDAs from Sheet
Just noticed I had been tagged in this thread. Interesting - though not that surprising - the old 'Evaluate' method doesn't fully support dynamic array formulas.
RE: 'Currying', as Peter says, refers to passing function parameters one at a time as a sequence of evaluations, I posted an example, when I had access to LAMBDA, in a reply to this post.
If one splits function parameters into groups of more than one input this technique is usually referred to as 'Partial Application', eg one can rewrite INDEX(A,x,y) as Array(A)(x,y) by defining the name,
Array:=LAMBDA(A,LAMBDA(x,y,INDEX(A,x,y)))This allows one to access arrays using index notation eg: X:=Array({1,2;3,4}) -> X(1,2) = 2
lori_mThanks for both the link to your currying example and this partial application construction, these will give me something to play with. I've been trying to figure out why you need a dummy character to end your series of parameters. Why doesn't something like this work?
ADD := LAMBDA(a,LAMBDA(b,IFERROR(ADD(a+b),a)))
I've wrestled with it off an on all day, testing various sorts of error-handling, but always back with some variation of your original construction that needs a "superfluous" parameter to throw a proper error.
- lori_mFeb 27, 2021Iron Contributor
Interested to try out that TEXTTOARRAY function when I can and see what they say at Ignite. There are a few clues in that POPL 2021 link including 'array-processing combinators, such as MAP and REDUCE" and 'VSCAN/HSCAN' for cumulative aggregations (all listed in the funcalc docs.)
- SergeiBaklanFeb 26, 2021Diamond Contributor
Perhaps recursion limit is the main concern, but not only. I hope we will have another iteration of lambdas soon - Ignite and some other events are coming, that's usual time to announce such kind of news.
By the way, failed with recursion version on test function Excel, TEXTTOARRAY() while waiting for the production LAMBDA() | LinkedIn , practical limit is quite low.
- lori_mFeb 25, 2021Iron Contributor
Good info, thanks for posting. I'd recommend 'Computerphile' which has some nice videos at a basic level (like mine). After going through some of that material I concluded the modified combinator method I linked to before needs a while loop so wouldn't help with recursion limits.
There's also a 'Funcalc' spreadsheet project that is the basis of some of the Microsoft Research material, details of which can be found here. It does look like Excel is heading toward a fully fledged functional programming language!
- tbouldenFeb 25, 2021Iron Contributor
lori_m PeterBartholomew1 This got me going down a rabbit hole, and I certainly don't imply that I know what I've been doing, but I think it's helping me get my head wrapped around it (slowly).
Based on the links I ended up doing some googling, and this is something I missed skimming the Microsoft https://www.microsoft.com/en-us/research/blog/lambda-the-ultimatae-excel-worksheet-function/ the first time: the GIF shows their construction of the Z/fixed point combinator.
I searched a bit more to find a derivation of the Z combinator, and came across https://thenewobjective.com/types-and-programming-languages/deriving-the-z-combinator#fixed-points-and-combinators, which seemed reasonably "accessible" (obvious scare quotes due to subject material). So I set about trying to step through these constructions in my LET/LAMBDA testing spreadsheet; please see attached. There were a few interim steps that I couldn't figure out how to implement, but ultimately the final "fact_16" is very similar to the "my_fact" I got from the Microsoft gif. I'm going to be getting some textbooks I haven't looked at in 20 years out over the weekend to try and remember the very little I "learned" about lambda calculus to facilitate making sense of this, because its mostly been pattern matching through the exercise.
- lori_mFeb 24, 2021Iron Contributor
Dunno, I suppose it's to do with exception handling - some other languages also need a terminator of some sort. The TYPE function was used instead of ISERROR because it always returns a single value so can handle array parameters more easily.
I'd be interested to know if there's a workaround for the recursion limits which are quite restrictive at the moment. If Excel doesn't optimise tail recursion something like this might work (though I struggle to get my head around it!)