res-sheets: implement modern dynamic-array and lambda functions (LET, LAMBDA, MAP, REDUCE, ARRAYFORMULA, SEQUENCE, etc.) #14
Labels
No labels
harness
proj-core-console
proj-core-demo
proj-core-edit
proj-core-init
proj-core-lib
proj-core-login
proj-core-res
proj-core-sh
proj-core-theme
proj-docs
proj-extra-calc
proj-extra-code
proj-extra-playbook
proj-extra-sheets
proj-harness
proj-os
residual
tier-0-trivial
tier-1-easy
tier-2-medium
tier-3-hard
tier-4-major
tier-5-epic
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
residual/.agent#14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
A user provided a massive real-world lambda formula (
extra/test-eval.txt) that factorizes integers using modern Google Sheets / Excel dynamic-array functions. When converted to.sheet.csvand run throughres-sheets calc, the engine returns#VALUE!because the parser does not recognize the core functions the formula is built on.Concrete test case
File:
extra/test-eval.txtConverted CSV:
extra/test-eval.sheet.csv(input100in A1, formula in B1)Expected: a prime-factorization string like
2^2*5^2Actual:
#VALUE!Missing functions
The formula engine needs the following functions to evaluate the test case (and to reach parity with modern spreadsheet standards):
LETlet(name, value, expr))LAMBDAlambda(param, expr))MAPmap(array, lambda))REDUCEreduce(array, lambda, init))ARRAYFORMULASEQUENCEsequence(rows, [cols], [start], [step]))IFSLETSWITCHLETAdditionally, the formula uses
GCD,FLOOR,LOG,TEXTJOIN,MOD,FIND,MID,SUBSTITUTE,ISERROR,ROUND,PRODUCT,SQRT,LEFT,RIGHT,CONCAT,IF,PI,RADIANS,DEGREES,SIN,COS,TAN,ASIN,ACOS,ATAN,ATAN2,SINH,COSH,TANH,EXP,LN,LOG10,EVEN,ODD,FACT,COMBIN,PERMUT,SUMSQ,QUOTIENT,CEILING,MROUND,ROUNDDOWN,ROUNDUP,RAND,RANDBETWEEN,MEDIAN,MODE.SNGL,STDEV.P,STDEV.S,VAR.P,VAR.S,LARGE,SMALL,PERCENTILE.INC,QUARTILE.INC,COUNTA,COUNTBLANK,COUNTIF,COUNTIFS,SUMIF,SUMIFS,AVERAGEIF,AVERAGEIFS,MAXIFS,MINIFS,AND,OR,NOT,XOR,TRUE,FALSE,IFERROR,IFNA,LEN,UPPER,LOWER,PROPER,TRIM,REPT,CHAR,CODE,EXACT,VALUE,T,TEXT,DATE,TODAY,NOW,YEAR,MONTH,DAY,HOUR,MINUTE,SECOND,WEEKDAY,EDATE,EOMONTH,DATEDIF,DAYS,NETWORKDAYS,WORKDAY,ROW,COLUMN,ROWS,COLUMNS,CHOOSE,INDEX,MATCH,VLOOKUP,HLOOKUP— most of which are already implemented. The blocker is specifically the functional / array layer.Acceptance criteria
res-sheets calc extra/test-eval.sheet.csvproduces a meaningful result (not#VALUE!) for input100.lib/sheets/formula_test.go.evalCalldispatch pattern informula_eval.go.Related
extra/test-eval.txt— the original formulaextra/test-eval.sheet.csv— the converted CSV test fixturedocs/extra/extra.md— res-sheets documentation