Legacy EVALUATE in LAMBDA: Build/Test LAMBDAs from Sheet

%3CLINGO-SUB%20id%3D%22lingo-sub-2133924%22%20slang%3D%22en-US%22%3ELegacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2133924%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20working%20through%20my%20UnpackLet%20LAMBDA%2C%20I%20thought%20perhaps%20there%20might%20be%20an%20easier%20way%20to%20test%20a%20LAMBDA%20while%20building%20it%2C%20and%20I%20believe%20using%20the%20legacy%20EVALUATE()%20function%20that%20is%20available%20via%20Name%20Manager%20(see%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fexceloffthegrid.com%2Fturn-string-formula-with-evalute%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fexceloffthegrid.com%2Fturn-string-formula-with-evalute%2F%3C%2FA%3E)%20is%20a%20way%20to%20do%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%2C%20you'll%20have%20to%20save%20any%20spreadsheet%20with%20EVALUATE()%20in%20a%20Named%20Range%20as%20.xlsm.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdd%20this%20to%20the%20Name%20Manager%20and%20call%20it%20something%20appropriate%2C%20i.e.%20lambdaEVAL%3A%3C%2FP%3E%3CP%3E%3DLAMBDA(x%2CEVALUATE(x))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20you%20can%20evaluate%20a%20string%20as%20a%20formula.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22tboulden_0-1613323960460.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F254854i968B9A06548CFC9B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22tboulden_0-1613323960460.png%22%20alt%3D%22tboulden_0-1613323960460.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20do%20more%20complicated%20formulas%20and%20spread%20params%20across%20multiple%20cells%2C%20then%20TEXTJOIN%20them.%20This%20works%20for%20LETs%20and%20LAMBDAs%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22tboulden_1-1613324205643.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F254855i6688CE65522A07E2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22tboulden_1-1613324205643.png%22%20alt%3D%22tboulden_1-1613324205643.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20know%20all%20the%20limitations%20of%20this%2C%20but%20a%20prominent%20one%20is%20that%20you%20can't%20EVALUATE%20a%20string%20longer%20that%20255%20chars.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22tboulden_2-1613324367310.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F254856iE725BDA1E52B6326%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22tboulden_2-1613324367310.png%22%20alt%3D%22tboulden_2-1613324367310.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3EI%20have%20you%20in%20mind%20in%20that%20this%20may%20facilitate%20commenting%20on%20the%20parts%20of%20a%20LAMBDA%20as%20its%20being%20built.%20See%20%22LAMBDA%20Testing%22%20tab%20in%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2133924%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2134138%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2134138%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F933333%22%20target%3D%22_blank%22%3E%40tboulden%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20far%20my%20focus%20on%20the%20development%20of%20Lambda%20functions%20is%20to%20write%20VBA%20to%20upload%20a%20formula%20(a%20working%20formula%20or%20as%20text)%20to%20the%20refers%20to%20box%20of%20the%20associated%20name.%26nbsp%3B%26nbsp%3BI%20had%20wondered%20whether%20your%20'unpacked%20let'%20could%20to%20run%20through%20EVALUATE%20to%20test%20it%20but%20it%20seems%20size%20might%20be%20a%20problem.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20played%20with%20the%20naming%20of%20your%20function.%20'%CE%BB'%20was%20one%20choice%2C%20and%20gets%20points%20for%20being%20succinct%2C%20but%20the%20option%20that%20surprised%20me%20was%20to%20name%20it%20'EVALUATE'.%26nbsp%3B%20On%20the%20spreadsheet%2C%20the%20defined%20name%20took%20precedence%20over%20an%20illegal%20function%20but%20within%20the%20Lambda%20function%20it%20calls%20the%26nbsp%3BXLM%20function.%26nbsp%3B%20The%20result%20is%20that%2C%20to%20all%20intents%20and%20purposes%2C%20EVALUATE%20is%20now%20a%20valid%20worksheet%20function!%26nbsp%3B%20Maybe%20Lambda%20will%20allow%20a%20few%20other%20legacy%20functions%20to%20be%20rehabilitated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20give%20some%20thought%20to%20the%20documentation%20idea.%26nbsp%3B%20In%20the%20past%2C%20there%20were%20occasions%20when%20I%20wrote%20the%20documentation%20in%20the%20form%20of%20comments%20first%2C%20and%20only%20then%20filled%20in%20the%20gaps%20with%20code.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2138775%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138775%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F933333%22%20target%3D%22_blank%22%3E%40tboulden%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20to%20play%20with%20some%20of%20your%20ideas%20but%20it%20may%20be%20that%20EVALUATE%20has%20some%20limitations%20when%20applied%20to%20modern%20dynamic%20arrays.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255204iC4DFACA3F08A3C3B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2139304%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139304%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3EYou're%20onto%20something%3B%20I%20tried%20unpacking%20your%20LET%20function%20using%20my%20previous%20UnpackLet%20LAMBDA%20and%20that%20formula%20works%2C%20but%20EVAL%20of%20that%20formula%20yields%20same%20result%20as%20your%20EVAL(%22LET...%22)%2C%20being%20the%20first%20value%20in%20the%201-d%20array.%20Will%20play%20with%20it%20some%20more%20as%20well%3B%20not%20ready%20to%20throw%20it%20out%20just%20yet%2C%20and%20the%20more%20limitations%20we're%20aware%20of%20will%20prevent%20unnecessary%20frustration.%20Thanks!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2152307%22%20slang%3D%22en-US%22%3ERE%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2152307%22%20slang%3D%22en-US%22%3ENewer%20versions%20than%201907%20Excel%2C%20calculation%20is%20broken.%20xlcalculationAutomatic%20will%20take%20over%2050times%20longer%20in%20new%20versions%20(2012%20and%202101)%20than%20early%20versions.%20Its%20totally%20screwed%20up.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2152646%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2152646%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F933333%22%20target%3D%22_blank%22%3E%40tboulden%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWell%20done.%20I%20was%20sure%20I%20had%20tried%20the%20old%3C%2FP%3E%3CP%3E%3CSTRONG%3EN(IF(1%2Carr))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Eformula%20in%20the%20%3CSTRONG%3EINDEX%3C%2FSTRONG%3E%20but%20clearly%20I%20got%20something%20wrong.%3C%2FP%3E%3CP%3EI%20decided%20that%2C%20if%20I%20wasn't%20allowed%20'n'%20as%20a%20formula-local%20name%2C%20I%20would%20switch%20to%20Unicode%20symbols.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20381px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256356i9318A373B4C13AD2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EOne%20perfectly%20legal%20Lambda%20that%20I%20amused%20myself%20with%20recently%20was%3C%2FP%3E%3CP%3E%3D%20%E2%88%9A(x%C2%B2%2By%C2%B2)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2153636%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2153636%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3EI'm%20afraid%20I'm%20not%20picking%20up%20your%20comment%20re%3A%20the%20hypoteneuse%20LAMBDA%2C%20perhaps%20I'm%20dense%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20got%20another%20bit%20of%20troubleshooting%20I%20might%20like%20your%20help%20with%2C%20if%20you'll%20indulge%20me.%20As%20originally%20stated%20in%20the%20thread%20subject%2C%20I'm%20trying%20to%20refine%20using%20EVALUATE%20to%20make%20a%20nice%20worksheet-based%20%22environment%22%20for%20testing%20LET%2FLAMBDAs%20during%20construction.%20I've%20recently%20tried%20putting%20together%20your%20FOREACH%20and%20XSTACK%20in%20this%20%22environment%22%20and%20run%20into%20trouble%20with%20FOREACH%2C%20particularly%20passing%20in%20a%20function%20as%20a%20parameter.%20If%20doing%20so%20with%20LET%20and%20EVAL%2C%20it%20works%20happily%3B%20for%20LAMBDA%20I'm%20extremely%20confused.%20I%20can%20pass%20in%20the%20Name%20Manager-based%20LAMBDA%20(Iterate%2C%20in%20this%20example)%20and%20the%20following%20construction%20returns%20%22128%22%20as%20expected%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DEVAL(LAMBDA(function%2CTYPE(function)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20if%20I%20try%20to%20apply%20function%20as%20in%20the%20following%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DEVAL(LAMBDA(function%2Cfunction(1)))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20given%20%23NAME%3F.%20Please%20see%20attached%20for%20more%20detail%2C%20and%20thanks%20in%20advance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2153696%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2153696%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F933333%22%20target%3D%22_blank%22%3E%40tboulden%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20only%20just%20seen%20your%20post%20so%20this%20represents%20fresh%20thoughts%20rather%20than%20a%20reply.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20attachment%20uses%20a%20problem%20with%20a%202-D%20array%20of%20number%20triples%20and%20seeks%20to%20return%20the%20maximum%20of%20each%20triple%20as%20an%20array.%26nbsp%3B%20The%20problem%20arose%20within%20the%20Chandoo%20forum%20but%20the%20thing%20of%20interest%20for%20me%20was%20the%20structure%20and%20role%20of%20the%20nested%26nbsp%3B%CE%BB-functions%20that%20may%20be%20combined%20to%20provide%20a%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20share%20your%20interest%20in%20providing%20techniques%20that%20make%20the%20modern%20function%20easier%20to%20use%20and%20debug.%26nbsp%3B%20In%20this%20workbook%2C%20I%20have%20provided%20a%20VBA%20macro%20that%20allows%20the%20user%20to%20specify%20the%26nbsp%3B%CE%BB-function%20as%20a%20working%20function%20on%20the%20spreadsheet.%26nbsp%3B%20%3CSTRONG%3EFORMULATEXT%3C%2FSTRONG%3E%20is%20used%20to%20make%20the%20formula%20visible%20and%20the%20function%20can%20be%20named%20and%20a%20comment%20provided.%26nbsp%3B%20The%20macro%20uploads%20the%20name%20definition%2C%20by-passing%20the%20need%20for%20Name%20Manager.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20also%20included%20a%20working%20version%20of%20the%20formula%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20%E2%88%9A(x%C2%B2%2By%C2%B2)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ewithin%20the%20second%20file.%26nbsp%3B%20It%20is%20just%20'smoke%20and%20mirrors'%20implemented%20using%20the%26nbsp%3B%CE%BB-function%2C%20'%3CSTRONG%3E%E2%88%9A%3C%2FSTRONG%3E'%20which%20is%20defined%20to%20be%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DLAMBDA(a%2CSQRT(a))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20think%20it%20does%20look%20prettier%20than%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20IMABS(COMPLEX(x%2Cy))%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ewhich%20will%20also%20do%20the%20job.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F256403iAA4291617013A665%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2154624%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2154624%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3EMarvelous%2C%20that%20is%20much%20more%20pleasant%20to%20look%20at!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20experimented%20with%20your%20Array%20MAX%20Item%20spreadsheet%20and%20added%20another%20LAMBDA%20I've%20been%20working%20on%2C%20see%20%CE%BB%E2%82%83%20in%20the%20name%20manager%3B%20your%20VBA%20code%20is%20a%20reasonable%20person's%20implementation%20of%20what%20I'm%20trying%20to%20do%20with%20it%20conceptually.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%CE%BB%E2%82%83%20%3D%20LAMBDA(name%2Carg%E2%82%81%2Carg%E2%82%82%2Carg%E2%82%83%2C%CE%BB_EVAL(INDEX(Definitions%2CMATCH(name%2CNames%2C0))%26amp%3B%22(%22%26amp%3Barg%E2%82%81%26amp%3B%22%2C%22%26amp%3Barg%E2%82%82%26amp%3B%22%2C%22%26amp%3Barg%E2%82%83%26amp%3B%22)%22))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20introduced%20a%20sheet%20%22Repository%22%20with%202%20named%20ranges%20%22Names%22%20and%20%22Definitions%22%2C%20and%20populated%20them%20with%20the%20details%20for%20your%20LAMBDA%20Array%2C%20slightly%20massaged%20to%20cooperate%20with%20EVALUATE.%20%CE%BB%E2%82%83%20takes%20a%20name%20and%203%20arguments%2C%20and%20does%20a%20look-up%20on%20the%20definition%2C%20concatenates%20the%203%20args%20and%20the%20required%20trappings%20(I%20admit%20this%20is%20ugly%2C%20trying%20to%20come%20up%20with%20something%20cleaner).%20Once%20constructed%2C%20it%20then%20EVALUATEs%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUse%20it%20in%20a%20cell%20like%20so%20%3D%CE%BB%E2%82%83(%22Array%22%2CT%2CS%2C2)%20and%20it%20should%20be%20the%20same%20as%20your%20original%20construction%20%3DArray(T%2C%20S%2C%202).%20I've%20set%20this%20up%20with%201%20arg%20%3D%20%CE%BB%E2%82%81%2C%202%20arg%20%3D%20%CE%BB%E2%82%82%2C%20and%20now%203%20arg%20%3D%20%CE%BB%E2%82%83%20and%20its%20worked%20with%20a%20little%20massaging.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever!!%20DataRange%20is%20a%20RANDARRAY%20introduces%20something%20I%20didn't%20suspect%2C%20but%20makes%20sense%20now%20that%20I've%20seen%20it.%20My%20%CE%BB%E2%82%83%20doesn't%20update%20as%20often%20as%20your%20Array%20function%3B%20I%20have%20to%20change%20something%20in%20the%20named%20ranges%20for%20the%20functions%20to%20be%20in%20sync.%20I%20tried%20doing%20a%20plain%20%CE%BB_EVAL%20in%20the%20sheet%2C%20which%20is%20worse!%20It%20only%20reacts%20to%20changes%20in%20the%20spill%20range.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EInteresting!!%20My%20list%20of%20limitations%20is%20growing%2C%20though.%20As%20I%20said%20before%2C%20the%20VBA%20approach%20you're%20taking%20is%20seeming%20very%20reasonable%20at%20this%20point.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2155453%22%20slang%3D%22en-US%22%3ERe%3A%20Legacy%20EVALUATE%20in%20LAMBDA%3A%20Build%2FTest%20LAMBDAs%20from%20Sheet%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2155453%22%20slang%3D%22en-US%22%3EHaha%2C%20that%20sort%20of%20wizardry%20does%20just%20the%20trick!!%20Thanks!!%3CBR%20%2F%3E%3CBR%20%2F%3EI%20forgot%20to%20ask%2C%20but%20is%20my%20lambdifying%20%22trick%22%20an%20example%20of%20what%20I've%20seen%20you%20refer%20to%20as%20currying%3F%20I%20started%20doing%20a%20bit%20of%20research%2C%20but%20didn't%20dive%20in%20to%20deeply.%20I%20suspect%20knowing%20more%20about%20it%20will%20help%20figure%20out%20why%20my%20passing%20a%20function%20isn't%20currently%20working%20fully%20as%20expected%2C%3C%2FLINGO-BODY%3E
Contributor

In working through my UnpackLet LAMBDA, I thought perhaps there might be an easier way to test a LAMBDA while building it, and I believe using the legacy EVALUATE() function that is available via Name Manager (see here: https://exceloffthegrid.com/turn-string-formula-with-evalute/) is a way to do that.

 

Note, you'll have to save any spreadsheet with EVALUATE() in a Named Range as .xlsm.

 

Add this to the Name Manager and call it something appropriate, i.e. lambdaEVAL:

=LAMBDA(x,EVALUATE(x))

 

Now you can evaluate a string as a formula.

tboulden_0-1613323960460.png

 

You can do more complicated formulas and spread params across multiple cells, then TEXTJOIN them. This works for LETs and LAMBDAs

tboulden_1-1613324205643.png

 

I don't know all the limitations of this, but a prominent one is that you can't EVALUATE a string longer that 255 chars.

tboulden_2-1613324367310.png

 

@Peter BartholomewI have you in mind in that this may facilitate commenting on the parts of a LAMBDA as its being built. See "LAMBDA Testing" tab in attached.

 

 

20 Replies

@tboulden 

So far my focus on the development of Lambda functions is to write VBA to upload a formula (a working formula or as text) to the refers to box of the associated name.  I had wondered whether your 'unpacked let' could to run through EVALUATE to test it but it seems size might be a problem. 

 

I played with the naming of your function. 'λ' was one choice, and gets points for being succinct, but the option that surprised me was to name it 'EVALUATE'.  On the spreadsheet, the defined name took precedence over an illegal function but within the Lambda function it calls the XLM function.  The result is that, to all intents and purposes, EVALUATE is now a valid worksheet function!  Maybe Lambda will allow a few other legacy functions to be rehabilitated.

 

I will give some thought to the documentation idea.  In the past, there were occasions when I wrote the documentation in the form of comments first, and only then filled in the gaps with code.

@tboulden 

I tried to play with some of your ideas but it may be that EVALUATE has some limitations when applied to modern dynamic arrays.

image.png

@Peter BartholomewYou're onto something; I tried unpacking your LET function using my previous UnpackLet LAMBDA and that formula works, but EVAL of that formula yields same result as your EVAL("LET..."), being the first value in the 1-d array. Will play with it some more as well; not ready to throw it out just yet, and the more limitations we're aware of will prevent unnecessary frustration. Thanks!!

@Peter BartholomewIn researching this further, I've covered territory that you and @lori_m were traversing prior to the implementation of dynamic arrays: de-referencing and coercion! Due to the primordial nature of EVALUATE, these results would previously have required CSE I think, so we have to provide some incentive at times for it to give us what we want. Please see attached! I'm glad this is a thing of the past, but it is very interesting to learn about, kind of like working on your own car.

Newer versions than 1907 Excel, calculation is broken. xlcalculationAutomatic will take over 50times longer in new versions (2012 and 2101) than early versions. Its totally screwed up.

@tboulden 

Well done. I was sure I had tried the old

N(IF(1,arr))

formula in the INDEX but clearly I got something wrong.

I decided that, if I wasn't allowed 'n' as a formula-local name, I would switch to Unicode symbols.

image.png

One perfectly legal Lambda that I amused myself with recently was

= √(x²+y²)

 

@Peter BartholomewI'm afraid I'm not picking up your comment re: the hypoteneuse LAMBDA, perhaps I'm dense?

 

I've got another bit of troubleshooting I might like your help with, if you'll indulge me. As originally stated in the thread subject, I'm trying to refine using EVALUATE to make a nice worksheet-based "environment" for testing LET/LAMBDAs during construction. I've recently tried putting together your FOREACH and XSTACK in this "environment" and run into trouble with FOREACH, particularly passing in a function as a parameter. If doing so with LET and EVAL, it works happily; for LAMBDA I'm extremely confused. I can pass in the Name Manager-based LAMBDA (Iterate, in this example) and the following construction returns "128" as expected:

 

=EVAL(LAMBDA(function,TYPE(function)))

 

However, if I try to apply function as in the following:

 

=EVAL(LAMBDA(function,function(1)))

 

I'm given #NAME?. Please see attached for more detail, and thanks in advance!

@tboulden 

I have only just seen your post so this represents fresh thoughts rather than a reply.

 

The attachment uses a problem with a 2-D array of number triples and seeks to return the maximum of each triple as an array.  The problem arose within the Chandoo forum but the thing of interest for me was the structure and role of the nested λ-functions that may be combined to provide a solution.

 

I share your interest in providing techniques that make the modern function easier to use and debug.  In this workbook, I have provided a VBA macro that allows the user to specify the λ-function as a working function on the spreadsheet.  FORMULATEXT is used to make the formula visible and the function can be named and a comment provided.  The macro uploads the name definition, by-passing the need for Name Manager.

 

I have also included a working version of the formula 

= √(x²+y²)

within the second file.  It is just 'smoke and mirrors' implemented using the λ-function, '' which is defined to be

=LAMBDA(a,SQRT(a))

I think it does look prettier than

= IMABS(COMPLEX(x,y))

which will also do the job.

image.png

@Peter BartholomewMarvelous, that is much more pleasant to look at!

 

I experimented with your Array MAX Item spreadsheet and added another LAMBDA I've been working on, see λ₃ in the name manager; your VBA code is a reasonable person's implementation of what I'm trying to do with it conceptually.

 

λ₃ = LAMBDA(name,arg₁,arg₂,arg₃,λ_EVAL(INDEX(Definitions,MATCH(name,Names,0))&"("&arg₁&","&arg₂&","&arg₃&")"))

 

I've introduced a sheet "Repository" with 2 named ranges "Names" and "Definitions", and populated them with the details for your LAMBDA Array, slightly massaged to cooperate with EVALUATE. λ₃ takes a name and 3 arguments, and does a look-up on the definition, concatenates the 3 args and the required trappings (I admit this is ugly, trying to come up with something cleaner). Once constructed, it then EVALUATEs it.

 

Use it in a cell like so =λ₃("Array",T,S,2) and it should be the same as your original construction =Array(T, S, 2). I've set this up with 1 arg = λ₁, 2 arg = λ₂, and now 3 arg = λ₃ and its worked with a little massaging.

 

However!! DataRange is a RANDARRAY introduces something I didn't suspect, but makes sense now that I've seen it. My λ₃ doesn't update as often as your Array function; I have to change something in the named ranges for the functions to be in sync. I tried doing a plain λ_EVAL in the sheet, which is worse! It only reacts to changes in the spill range.

 

Interesting!! My list of limitations is growing, though. As I said before, the VBA approach you're taking is seeming very reasonable at this point.

 

 

@tboulden 

What I was trying to do was to provide a better formula development environment than Name Manager and, at the same time, to avoid too many round trips between the worksheet and the name manager (especially problematic for recursive λ functions).  I hadn't attempted the formula walkthrough that you achieved using EVAL within a λ function. 

 

The idea is great and, where applicable, it contributes hugely to the process of testing or understanding a complex LET function.  Ultimately an extension of the concept to apply to recursive λ functions would be amazing but I will settle for one step along the way right now.

 

Do not bother about the random data, it is not important.  If you dislike seeing the result out of step with the source data, you could try

=λ_EVAL(IF(TODAY(), "LAMBDA(T,S,I,INDEX(DataRange,N(IF({1},T)),N(IF({1},I+3*(S-1)))))(T,S,2)") )

to make the function volatile.

Haha, that sort of wizardry does just the trick!! Thanks!!

I forgot to ask, but is my lambdifying "trick" an example of what I've seen you refer to as currying? I started doing a bit of research, but didn't dive in to deeply. I suspect knowing more about it will help figure out why my passing a function isn't currently working fully as expected,

@tboulden 

Sorry I have been somewhat unresponsive.  I seem to have got myself locked out of the forum when using my main machine.  Microsoft created a brand new (unwanted) ID for me when it noticed I had accessed a client company account to collaborate with them.  When I deleted the profile it went into a sulk and refuses to talk to me.  I am currently using a resurrected machine which still has my original ID.

 

As I understand it, 'Currying' is a term for the practice of passing functions to a Lambda function one at a time.  I think the function remains represented as a string until a full set of parameters are provided, when it gets evaluated.

No worries at all, I noticed the username change, but the language-style seemed consistent, so I figured it wasn't an impostor and that some circumstance had occurred to instigate the new name.

@tboulden 

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.

@tboulden 

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!)

@lori_m @Peter Bartholomew 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 article the first time: the GIF shows their construction of the Z/fixed point combinator.

 

tboulden_0-1614262754602.png

 

I searched a bit more to find a derivation of the Z combinator, and came across this, 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.

 

@tboulden 

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!

@lori_m 

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.