Fields of the spreadsheet can contain expressions, that can be calculated. To calculate these values, the input of the user must be converted to a data structure, which can then be used to calculate the result of that field.
These expressions can contain constants, operations, references to other fields or a parenthesized expression:
Constants:
0
,42
,10.2
,4e6
,7.5e8
Unary expression:
-expression
,expression!
Binary expression:
expression + expression
,expression / expression
References:
3:1
(third column, first row)Parenthesized expression:
(expression)
We will create these types in lib/model/expression.ts
. First we import factorial
, since we will need it later on.
import { factorial } from "./utils";