Audit existing LAMBDAs for array-lifting support#180
Merged
Conversation
Add a dispatcher to CELLTOPOS, POSTOCELL, MOVECELL, GRIDLOOKUP, INCEL so they MAP over multi-cell input instead of silently collapsing it to a scalar. The scalar body is preserved (defined as a LAMBDA inside LET, not as a separate workbook name) so existing scalar callers are unaffected. GRIDAREA and the constant-table helpers (DEFAULTARROWS, DEFAULTMOVEDELTAS, KNIGHTDELTAS, ARROWMOVES) are intentionally skipped per the issue's classification (array output / no scalar input). Adds array-input tests for each upgraded LAMBDA covering vertical, horizontal, and where useful 2D and range-of-cells inputs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per Tim's review, expand the audit beyond the maps set to cover every LAMBDA in the library. Upgrades (dispatcher added — silently collapsed or errored on array input): - NTH (array, lift on n): @INDEX(flat, idx, 1) collapses to first when idx is an array. - CHARQ (string, lift on Text): regex branch uses COLUMNS(REGEXEXTRACT(Text, Char, 1)) which returns one array per Text and doesn't compose across an array of Texts. - REVERSESTRING (string, lift on text): SEQUENCE(LEN(text), ...) requires a scalar length and errors when text is an array. - TLOOKUP (lookup, lift on Item): defensive dispatcher — MATCH may lift on lookup_value in modern Excel but a dispatcher makes the behaviour explicit and consistent with the other upgrades. Confirmation tests added (no code change — these already lift): - CONTAINS — XMATCH lifts on value - CIRCPOS — MOD lifts on moves and start (help already advertised this) Skipped (no scalar input, or output inherently an array): BICOL, BIROW, MAXOF, MINOF, NTHOCCURRENCE, CUMSUMGRID, MAXOCCUR, MINOCCUR, EXPANDDIMENSIONS, SNAQUENCE, WRITEAT, INSERTAT, REVERSEARRAY, ROTATE, EXPLODE, CONSECGROUPS, COMBINATIONS, COMBININDICES, SetVar, SetVars, SetState, NewState, FINDFIRST, FINDALL, REDUCEUNTIL, REDUCEWHILE, SCANUNTIL, SCANWHILE. GetVar/GetVarAt/SplitState already lift via built-in MAP over a column of states (no test added — existing tests already exercise the column path). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per #179, audit every LAMBDA in the library for array-lifting support. Apply the dispatcher pattern wherever a scalar-input/scalar-output LAMBDA silently collapses or errors on array input.
Upgrades (⚠️ dispatcher added)
CELLTOPOScellSUMPRODUCT(...SEQUENCE(LEN(letters))...)collapses arrays of addressesPOSTOCELLposMOVECELLcellGRIDLOOKUPvalueINCELaddressNTHn@INDEX(flat, idx, 1)collapses to first when idx is arrayCHARQTextCOLUMNS(REGEXEXTRACT(...))returns one array per Text, doesn't composeREVERSESTRINGtextSEQUENCE(LEN(text), ...)errors when text is arrayTLOOKUPItemAlready lifts (✅ no change — confirmation tests added where relevant)
CONTAINS— XMATCH lifts onvalueCIRCPOS— MOD lifts onmovesandstart(help already advertised this)GetVar/GetVarAt/SplitState— already MAP over a column of statesSkip (➖ no scalar input, or output inherently an array)
GRIDAREA,ARROWMOVES,DEFAULTARROWS,DEFAULTMOVEDELTAS,KNIGHTDELTAS,BICOL,BIROW,MAXOF,MINOF,NTHOCCURRENCE,CUMSUMGRID,MAXOCCUR,MINOCCUR,EXPANDDIMENSIONS,SNAQUENCE,WRITEAT,INSERTAT,REVERSEARRAY,ROTATE,EXPLODE,CONSECGROUPS,COMBINATIONS,COMBININDICES,SetVar,SetVars,SetState,NewState,FINDFIRST,FINDALL,REDUCEUNTIL,REDUCEWHILE,SCANUNTIL,SCANWHILE.Dispatcher shape
The scalar body is preserved inline as a LAMBDA inside
LET(rather than a separate<NAME>_SCALARworkbook name) — this keeps the namespace tidy and the logic in one file:The dispatcher sits after the
ISOMITTED(...)→ShowHelpbranch, so=CELLTOPOS()etc. still return help text. Scalar callers are unaffected.Test plan
dotnet test addin/lambda-boss.AddinTests— 382 pass (was 359 pre-change).dotnet test addin/lambda-boss.Tests— 828 pass.Closes #179
🤖 Generated with Claude Code