Forum Discussion
A generalised Lambda helper function that return arrays of arrays using bisection.
I have been away from home today so have yet to really get to grips with the concepts you are following. Firstly 'how?' and then 'why?'
Similarly there are joelb95 's ideas on 'stuffing' which I need to get to grips with.
Thunking vs. Stuffing - Is there a difference? - Microsoft Community Hub
Meanwhile I have continued to apply the Lambda functions that extend standard helper functions by automatically modifying the enclosed Lambda functions to return thunks rather than arrays. Once one has the array of thunks, the derivation matters little and I expand it using a binary tree using WRAPCOLS and MAP to bring thunks together pairwise. The idea of using array manipulation functions to operate upon arrays of thunks still seems to be pushing one's luck, but so far, so good!
Anyway JoeMcDaid has recently announced RegEx functionality within Excel so I set out to test it by modifying a version based upon VBA UDFs to implement regular expressions. I had already used thunks to return the entire dataset of Danish street addresses as a single array, so the new version of the workbook served to test the new functionality and the use of thunks [with permission from Hans Knudsen ].
The result is a 6401 x 6 array of text values which looks pretty unremarkable (as it should) until one sees the RegEx function feeding capture groups into a thunk array.
SergeiBaklan The file contains the thunk variant of BYROW but the RegEx might be equally relevant within your broad range of interests.
Great news about new regex functions! I had not been aware of this development. And I like the use of shaping functions with arrays of thunks, something along these lines was included in one of the functions in the gist.
I hope to be able to revert regarding the other topics raised but briefly for now relating to How/Why of lambda constructions,
How?
Consider the following two implementations where parameters may be values, arrays, lambdas, etc.
Thunk = LAMBDA(HSTACK(a,b,c,d))
Tuple = LAMBDA(i,CHOOSE(i,a,b,c,d))
In the Fibonacci example we have a 2-tuple or pair (x, y) that maps to (y, x+y) with initial value (0,1). The mapping is represented as i*x+y (i=0,1) or equivalently IF(i, x+y, y) with initial values x=0, y=1.
Why?
Both constructions can be nested to work around array of arrays. I've got less experience with thunks than you but my impressions are both have pros/cons including,
Thunks
- Easily modified / reshaped by updating the array and wrapping in lambda
- Extendable to longer lists via stacking functions.
Tuples/records:
- Arrays stored individually e.g. an accumulator can be built containing several variables.
- Efficient retrieval of data since IF/CHOOSE only evaluate selected arguments (versus indexing an arrays of thunks which can lead to inefficiencies)
Perhaps one could make a similar distinction between lists (mutable) vs tuples (immutable) in some other languages. I guess that other link you mention might be related though the terminology looks non-standard - at least to me.