Forum Discussion

tchoha888's avatar
tchoha888
Copper Contributor
Aug 07, 2023
Solved

Recursive LAMBDA and LET function problem

Can anyone tell me why my lambda function called "RecursionTest"           =LAMBDA(txt, LET( pos, FIND("x", txt), IF( ISERROR(pos), pos, LET( nextTx...
  • mtarler's avatar
    Aug 07, 2023

    OK so it gets funky here. If you try only 1 or 2 it works but after that it fails. Basically after the 1st next becomes an array and the conditional part of the IF statement has N elements the TRUE parameter is singular so applied across any array size, but the FALSE parameter is N+1 elements so when there are 2 the conditional at that time max at 1 and the output array of 2 is allowed but after that there are unequal dimensions on the conditional and the FALSE parameter resulting in a #NA (value not available) in 1 case. If instead you had VSTACK("xx","xx",next) then you will get 2 #NA because there will be 2 values not available as it tries to parse through the arrays. A possible solution to this might be using CONCAT:

    IF(ISERROR(CONCAT(next)), "xx", VSTACK("xx", next))

Resources