@@ -321,6 +321,8 @@ as per the floating point format standard IEEE-754.
321
321
Note that if ` isNaN ` is true, ` isNumber ` is also true (yes, ` NaN ` is a
322
322
number).
323
323
324
+ If this expression is a symbol, this lookup also causes binding to a definition.
325
+
324
326
</MemberCard >
325
327
326
328
<a id =" boxedexpression_isinfinity " name =" boxedexpression_isinfinity " ></a >
@@ -333,7 +335,9 @@ number).
333
335
readonly isInfinity : boolean ;
334
336
```
335
337
336
- The numeric value of this expression is ` ±Infinity ` or Complex Infinity
338
+ The numeric value of this expression is ` ±Infinity ` or ComplexInfinity.
339
+
340
+ If this is a symbol, causes it to be bound to a definition.
337
341
338
342
</MemberCard >
339
343
@@ -347,7 +351,7 @@ The numeric value of this expression is `±Infinity` or Complex Infinity
347
351
readonly isFinite : boolean ;
348
352
```
349
353
350
- This expression is a number, but not ` ±Infinity ` , ' ComplexInfinity` or
354
+ This expression is a number, but not ` ±Infinity ` , ` ComplexInfinity ` or
351
355
` NaN `
352
356
353
357
</MemberCard >
@@ -526,6 +530,9 @@ If a symbol, this does take assumptions into account, that is `this.sgn`
526
530
will return ` positive ` if the symbol is assumed to be positive
527
531
(using ` ce.assume() ` ).
528
532
533
+ For a symbol also, requires that the symbol be bound with its definition (i.e. canonical);
534
+ otherwise, will return ` undefined ` .
535
+
529
536
</MemberCard >
530
537
531
538
<a id =" boxedexpression_ispositive " name =" boxedexpression_ispositive " ></a >
@@ -895,7 +902,7 @@ If false, the value of the expression may change, if the
895
902
value of other expression changes or for other reasons.
896
903
897
904
If ` this .isPure ` is ` false ` , ` this .value ` is undefined. Call
898
- ` this .evaluate ()` to determine the value of the expression instead.
905
+ ` this .evaluate ()` (or '*this.N()*') to determine the value of the expression instead.
899
906
900
907
As an example, the ` Random ` function is not pure.
901
908
@@ -915,15 +922,18 @@ Applicable to canonical and non-canonical expressions.
915
922
readonly isConstant : boolean ;
916
923
` ` `
917
924
918
- True if the the value of the expression does not depend on the value of
919
- any other expression.
925
+ ` True ` if this expression's value remains constant.
926
+
927
+ If *true* and a function, implies that it is *pure*, and also that all of its arguments are
928
+ constant.
920
929
921
- For example, a number literal, a symbol with a constant value.
930
+ Number literals, symbols with constant values, and numeric functions with constant
931
+ subexpressions may all be considered *constant*, i.e.:
922
932
- ` 2 ` is constant
923
933
- ` Pi ` is constant
924
934
- ` [" Add" , " Pi" , 2 ]` is constant
925
- - ` x ` is not constant
926
- - ` [" Add" , " x" , 2 ]` is not constant
935
+ - ` x ` is inconstant: unless declared with a constant value.
936
+ - ` [" Add" , " x" , 2 ]` is either constant or inconstant, depending on whether ` x ` is constant.
927
937
928
938
</MemberCard>
929
939
@@ -1494,7 +1504,8 @@ For symbols and functions, a definition associated with the
1494
1504
definition.
1495
1505
1496
1506
:::info[Note]
1497
- ` undefined ` if not a canonical expression.
1507
+ For a symbol, always binds - potentially creating - a definition. For ` BoxedFunctions ` , will
1508
+ return ` undefined ` if not canonical.
1498
1509
:::
1499
1510
1500
1511
</MemberCard>
@@ -1529,6 +1540,8 @@ readonly symbolDefinition: BoxedSymbolDefinition;
1529
1540
1530
1541
For symbols, a definition associated with the expression.
1531
1542
1543
+ Bind the expression to a definition, if not already bound.
1544
+
1532
1545
Return ` undefined ` if not a symbol
1533
1546
1534
1547
</MemberCard>
@@ -1770,14 +1783,21 @@ Return a JavaScript primitive representing the value of this expression.
1770
1783
1771
1784
Equivalent to ` expr .N ().valueOf ()` .
1772
1785
1773
- Only the value of variables can be changed (symbols that are not
1774
- constants).
1786
+ For functions, will only return non-undefined (i.e., compute the value) if the function is pure.
1775
1787
1776
- Throws a runtime error if a constant.
1788
+ For symbols, the current behaviour also considers *non-constant* values, including those weakly
1789
+ assigned via symbol assumptions.
1777
1790
1778
- :::info[Note]
1779
- If non-canonical, does nothing
1780
- :::
1791
+ **note**: this property is not guaranteed to remain constant, potentially differing across
1792
+ subsequent calls if a symbol (non-constant), or an *inconstant* pure function.
1793
+
1794
+ Set the value of this expression (applicable only to ` BoxedSymbol ` ).
1795
+
1796
+ Will throw a runtime error if either not a BoxedSymbol, or if a symbol expression which is
1797
+ non-variable/constant.
1798
+
1799
+ Setting the value of a symbol results in the forgetting of all assumptions about it in the
1800
+ current scope.
1781
1801
1782
1802
</MemberCard>
1783
1803
@@ -1815,6 +1835,7 @@ If a symbol the type of the value of the symbol.
1815
1835
If not valid, return ` " error" ` .
1816
1836
If non-canonical, return ` undefined ` .
1817
1837
If the type is not known, return ` " unknown" ` .
1838
+ If a symbol with a 'function' definition, returns the 'signature' type.
1818
1839
:::
1819
1840
1820
1841
</MemberCard>
@@ -1829,7 +1850,10 @@ If the type is not known, return `"unknown"`.
1829
1850
isCollection : boolean ;
1830
1851
` ` `
1831
1852
1832
- Return true if the expression is a collection: a list, a vector, a matrix, a map, a tuple, etc...
1853
+ Return true if the expression is a collection: a list, a vector, a matrix, a map, a tuple,
1854
+ etc...
1855
+
1856
+ For symbols, this check involves binding to a definition, if not already canonical.
1833
1857
1834
1858
</MemberCard>
1835
1859
@@ -2571,7 +2595,8 @@ it was provided.
2571
2595
2572
2596
- ` InvisibleOperator ` : replace use of the ` InvisibleOperator ` with
2573
2597
another operation, such as multiplication (i.e. ` 2x ` or function
2574
- application ( ` f (x )` ).
2598
+ application ( ` f (x )` ). Also replaces ['InvisibleOperator', real, imaginary] instances with
2599
+ complex (imaginary) numbers.
2575
2600
- ` Number ` : replace all numeric values with their
2576
2601
canonical representation, for example, reduce
2577
2602
rationals and replace complex numbers with no imaginary part with a real number.
@@ -2783,6 +2808,8 @@ type Rule =
2783
2808
| RuleConditionFunction ;
2784
2809
useVariations : boolean ;
2785
2810
id : string ;
2811
+ onBeforeMatch : (rule , expr ) => void ;
2812
+ onMatch : (rule , expr , replace ) => void ;
2786
2813
};
2787
2814
` ` `
2788
2815
@@ -2838,6 +2865,8 @@ type BoxedRule = {
2838
2865
condition: undefined | RuleConditionFunction;
2839
2866
useVariations: boolean;
2840
2867
id: string;
2868
+ onBeforeMatch: (rule, expr) => void;
2869
+ onMatch: (rule, expr, replace) => void;
2841
2870
};
2842
2871
` ` `
2843
2872
@@ -3140,7 +3169,8 @@ optional value:
3140
3169
` ` ` ts
3141
3170
type FunctionDefinition = BaseDefinition & Partial < FunctionDefinitionFlags > & {
3142
3171
signature: | Type
3143
- | TypeString ;
3172
+ | TypeString
3173
+ | BoxedType ;
3144
3174
type : (ops , options ) =>
3145
3175
| Type
3146
3176
| TypeString
@@ -3168,7 +3198,8 @@ Definition record for a function.
3168
3198
` ` ` ts
3169
3199
optional signature :
3170
3200
| Type
3171
- | TypeString ;
3201
+ | TypeString
3202
+ | BoxedType ;
3172
3203
` ` `
3173
3204
3174
3205
The function signature.
@@ -4303,35 +4334,57 @@ This indicates a condition under which parsing should stop:
4303
4334
4304
4335
< / MemberCard >
4305
4336
4306
- < a id = " expressionparsehandler " name = " expressionparsehandler " > </a >
4337
+ < a id = " parsehandler " name = " parsehandler " > </a >
4307
4338
4308
4339
<MemberCard >
4309
4340
4310
- ### ExpressionParseHandler ()
4341
+ ### ParseHandler
4311
4342
4312
4343
` ` ` ts
4313
- type ExpressionParseHandler = (parser, until?) => Expression | null;
4344
+ type ParseHandler =
4345
+ | ExpressionParseHandler
4346
+ | SymbolParseHandler
4347
+ | FunctionParseHandler
4348
+ | EnvironmentParseHandler
4349
+ | PostfixParseHandler
4350
+ | InfixParseHandler
4351
+ | MatchfixParseHandler;
4314
4352
` ` `
4315
4353
4316
- Custom parsing handler .
4354
+ ** Custom parsing handler .**
4317
4355
4318
- When invoked the parser points right after the LaTeX fragment that triggered
4319
- this parsing handler .
4356
+ When this handler is invoked the parser points right after the LaTeX
4357
+ fragment that triggered it .
4320
4358
4321
- The parser should be moved , by calling ` parser.nextToken() ` for
4322
- every consumed token .
4359
+ Tokens can be consumed with ` parser.nextToken() ` and other parser methods
4360
+ such as ` parser.parseGroup() ` , ` parser.parseOptionalGroup() ` , etc .. .
4323
4361
4324
4362
If it was in an infix or postfix context , ` lhs ` will represent the
4325
4363
left - hand side argument . In a prefix or matchfix context , ` lhs ` is ` null ` .
4326
4364
4327
- In a superfix (^ ) or subfix (_ ) context (that is if the first token of the
4328
- trigger is ` ^ ` or ` _ ` ), lhs is ` ["Superscript", lhs, rhs] `
4365
+ In a superfix (` ^ ` ) or subfix (` _ ` ) context (that is if the first token of
4366
+ the trigger is ` ^ ` or ` _ ` ), ` lhs ` is ` ["Superscript", lhs, rhs] `
4329
4367
and ` ["Subscript", lhs, rhs] ` , respectively .
4330
4368
4331
- The handler should return ` null ` if the expression could not be parsed
4332
- (didn ' t match the syntax that was expected). The matching expression
4369
+ The handler should return ` null ` if the tokens could not be parsed
4370
+ (didn ' t match the syntax that was expected), or the matching expression
4333
4371
otherwise .
4334
4372
4373
+ If the tokens were parsed but should be ignored , the handler should
4374
+ return ` Nothing ` .
4375
+
4376
+ < / MemberCard >
4377
+
4378
+ < a id = " expressionparsehandler" name = " expressionparsehandler" > </a >
4379
+
4380
+ <MemberCard >
4381
+
4382
+ ### ExpressionParseHandler ()
4383
+
4384
+ ` ` ` ts
4385
+ type ExpressionParseHandler = (parser, until?) => Expression | null;
4386
+ ` ` `
4387
+
4335
4388
< / MemberCard >
4336
4389
4337
4390
< a id = " prefixparsehandler" name = " prefixparsehandler" > </a >
0 commit comments