LAMBDA: Recursive Lists and Understanding Recursion Limits of LAMBDA

Frequent Contributor

I think I've found the most intuitive way (for me, at least) to clearly demonstrate the current recursion limits in Excel for LAMBDA functions: recursive lists.


Obligatory link for intro to LAMBDA recursion which has this gem toward the end: Furthermore, do note that the current operand stack limit in Excel is 1,024. This should be borne in mind together with calculation times, as the current recursion limit is set as 1,024 divided by (number of lambda parameters + 1).


In attached spreadsheet I go about demonstrating this relationship by building a recursive list that takes two main parameters: passing the LAMBDA to itself as "ME", and the current list. The recursive LAMBDA iteratively pushes numbers to the head of the list and we inspect the completed list. To demonstrate the effect of additional parameters, I add additional placeholders that contribute nothing to building the list and only take up space in memory. As we increase parameter count, the length of our list converges on the theoretical limit of 1024/(parameter count + 1), but for 2 and 3 parameters the is a higher difference, and I'm not sure what to attribute this to.


Any folks with a comp-sci background that can enlighten? Thanks in advance!

1 Reply
  1. Updated for the obvious missing cases: param Ct = 1 and param Ct = 253 (max allowable). param Ct = 1 case has a higher diff to theoretical that is greater still.