@cortex-js/compute-engine 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +8491 -7432
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +41 -88
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -5
- package/dist/types/common/utils.d.ts +1 -0
- package/dist/types/compute-engine/assume.d.ts +6 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +10 -15
- package/dist/types/compute-engine/boxed-expression/box.d.ts +74 -16
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +10 -5
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +16 -15
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +20 -20
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +8 -7
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +2 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +18 -13
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +18 -0
- package/dist/types/compute-engine/compute-engine.d.ts +65 -33
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +2 -8
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +25 -9
- package/dist/types/compute-engine/latex-syntax/public.d.ts +14 -6
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +3 -3
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +5 -6
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +3 -2
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/numerics/{numeric-decimal.d.ts → numeric-bignum.d.ts} +10 -6
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +10 -6
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +56 -0
- package/dist/types/compute-engine/public.d.ts +205 -254
- package/dist/types/compute-engine/rules.d.ts +7 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +2 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +30 -12
- package/dist/types/compute-engine/symbolic/sum.d.ts +13 -7
- package/dist/types/compute-engine/symbolic/utils.d.ts +7 -29
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +2 -2
- package/dist/types/math-json/utils.d.ts +11 -41
- package/dist/types/math-json.d.ts +3 -3
- package/package.json +1 -1
package/dist/math-json.esm.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
2
|
-
/**
|
|
3
|
-
* These constants are the 'primitive' functions and constants that are used
|
|
4
|
-
* for some basic manipulations such as parsing, and transforming to canonical
|
|
5
|
-
* form.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
1
|
+
/** MathJSON 0.10.0 */
|
|
8
2
|
function isSymbolObject(expr) {
|
|
9
3
|
return expr !== null && typeof expr === 'object' && 'sym' in expr;
|
|
10
4
|
}
|
|
@@ -17,14 +11,12 @@ function isFunctionObject(expr) {
|
|
|
17
11
|
function isDictionaryObject(expr) {
|
|
18
12
|
return expr !== null && typeof expr === 'object' && 'dict' in expr;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
(!Array.isArray(expr) &&
|
|
27
|
-
(typeof expr !== 'object' || !('fn' in expr || 'dic' in expr))));
|
|
14
|
+
function isValidIdentifier(s) {
|
|
15
|
+
// An identifier must not contain any of these characters
|
|
16
|
+
if (/[\u0000-\u0020\u0022\u0060\ufffe\uffff]/.test(s))
|
|
17
|
+
return false;
|
|
18
|
+
// A symbol name must not start with one these characters
|
|
19
|
+
return !/^[\u0021\u0022\u0024-\u0029\u002e\u003a\u003f\u0040\u005b\u005d\u005e\u007b\u007d\u007e\+\-[0-9]]/.test(s);
|
|
28
20
|
}
|
|
29
21
|
/** If expr is a string literal, return it.
|
|
30
22
|
*
|
|
@@ -45,7 +37,7 @@ function stringValue(expr) {
|
|
|
45
37
|
return expr.substring(1, expr.length - 1);
|
|
46
38
|
}
|
|
47
39
|
/**
|
|
48
|
-
* The head of a function can be
|
|
40
|
+
* The head of a function can be an identifier or an expression.
|
|
49
41
|
*
|
|
50
42
|
* Return `null` if the expression is not a function.
|
|
51
43
|
*
|
|
@@ -56,8 +48,11 @@ function stringValue(expr) {
|
|
|
56
48
|
function head(expr) {
|
|
57
49
|
if (expr === null || expr === undefined)
|
|
58
50
|
return null;
|
|
59
|
-
if (Array.isArray(expr))
|
|
51
|
+
if (Array.isArray(expr)) {
|
|
52
|
+
console.assert(expr.length > 0 &&
|
|
53
|
+
(typeof expr[0] !== 'string' || isValidIdentifier(expr[0])));
|
|
60
54
|
return expr[0];
|
|
55
|
+
}
|
|
61
56
|
if (isFunctionObject(expr))
|
|
62
57
|
return expr.fn[0];
|
|
63
58
|
return null;
|
|
@@ -67,15 +62,6 @@ function headName(expr) {
|
|
|
67
62
|
const h = head(expr);
|
|
68
63
|
return typeof h === 'string' ? h : '';
|
|
69
64
|
}
|
|
70
|
-
function op(expr, n) {
|
|
71
|
-
if (expr === null || expr === undefined)
|
|
72
|
-
return null;
|
|
73
|
-
if (Array.isArray(expr))
|
|
74
|
-
return expr[n] ?? null;
|
|
75
|
-
if (isFunctionObject(expr))
|
|
76
|
-
return expr.fn[n] ?? null;
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
65
|
/**
|
|
80
66
|
* Return all the elements but the first one, i.e. the arguments of a
|
|
81
67
|
* function.
|
|
@@ -89,6 +75,22 @@ function ops(expr) {
|
|
|
89
75
|
return expr.fn.slice(1);
|
|
90
76
|
return null;
|
|
91
77
|
}
|
|
78
|
+
/** Return the nth argument of a function expression */
|
|
79
|
+
function op(expr, n) {
|
|
80
|
+
if (expr === null || expr === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
if (Array.isArray(expr))
|
|
83
|
+
return expr[n] ?? null;
|
|
84
|
+
if (isFunctionObject(expr))
|
|
85
|
+
return expr.fn[n] ?? null;
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
function op1(expr) {
|
|
89
|
+
return op(expr, 1);
|
|
90
|
+
}
|
|
91
|
+
function op2(expr) {
|
|
92
|
+
return op(expr, 2);
|
|
93
|
+
}
|
|
92
94
|
function nops(expr) {
|
|
93
95
|
if (expr === null || expr === undefined)
|
|
94
96
|
return 0;
|
|
@@ -101,21 +103,26 @@ function nops(expr) {
|
|
|
101
103
|
function symbol(expr) {
|
|
102
104
|
if (expr === null || expr === undefined)
|
|
103
105
|
return null;
|
|
106
|
+
if (typeof expr === 'string') {
|
|
107
|
+
// Is it a number?
|
|
108
|
+
if (/^[+\-\.0-9]/.test(expr))
|
|
109
|
+
return null;
|
|
110
|
+
// Is it a string literal?
|
|
111
|
+
if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
104
114
|
const s = isSymbolObject(expr) ? expr.sym : expr;
|
|
105
115
|
if (typeof s !== 'string')
|
|
106
116
|
return null;
|
|
107
|
-
// Is it a string literal?
|
|
108
|
-
if (s.length >= 2 && s[0] === "'" && s[s.length - 1] === "'")
|
|
109
|
-
return null;
|
|
110
117
|
return s;
|
|
111
118
|
}
|
|
112
119
|
function keyValuePair(expr) {
|
|
113
120
|
const h = head(expr);
|
|
114
121
|
if (h === 'KeyValuePair' || h === 'Tuple' || h === 'Pair') {
|
|
115
|
-
const key = stringValue(
|
|
122
|
+
const key = stringValue(op1(expr));
|
|
116
123
|
if (!key)
|
|
117
124
|
return null;
|
|
118
|
-
return [key,
|
|
125
|
+
return [key, op2(expr) ?? 'Nothing'];
|
|
119
126
|
}
|
|
120
127
|
return null;
|
|
121
128
|
}
|
|
@@ -172,63 +179,9 @@ function mapArgs(expr, fn) {
|
|
|
172
179
|
i += 1;
|
|
173
180
|
}
|
|
174
181
|
return result;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Return num as a number if it's a valid JSON number (that is
|
|
178
|
-
* a valid JavaScript number but not NaN or +/-Infinity) or
|
|
179
|
-
* as a string otherwise
|
|
180
|
-
*/
|
|
181
|
-
function asValidJSONNumber(num) {
|
|
182
|
-
if (typeof num === 'string') {
|
|
183
|
-
const val = Number(num);
|
|
184
|
-
if (num[0] === '+')
|
|
185
|
-
num = num.slice(1);
|
|
186
|
-
if (val.toString() === num) {
|
|
187
|
-
// If the number roundtrips, it can be represented by a
|
|
188
|
-
// JavaScript number
|
|
189
|
-
// However, NaN and Infinity cannot be represented by JSON
|
|
190
|
-
if (isNaN(val) || !isFinite(val)) {
|
|
191
|
-
return val.toString();
|
|
192
|
-
}
|
|
193
|
-
return val;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return num;
|
|
197
|
-
}
|
|
198
|
-
// function number(
|
|
199
|
-
// expr: Expression | null | undefined
|
|
200
|
-
// ): number | string | null {
|
|
201
|
-
// if (expr === null || expr === undefined) return null;
|
|
202
|
-
// if (typeof expr === 'number') return expr;
|
|
203
|
-
// if (isNumberObject(expr)) return expr.num;
|
|
204
|
-
// return null;
|
|
205
|
-
// }
|
|
206
|
-
// export function isEqual(lhs: Expression, rhs: Expression): boolean {
|
|
207
|
-
// const symbLhs = symbol(lhs);
|
|
208
|
-
// if (symbLhs) return symbLhs === symbol(rhs);
|
|
209
|
-
// const strLhs = string(lhs);
|
|
210
|
-
// if (strLhs) return strLhs === string(rhs);
|
|
211
|
-
// if (Array.isArray(lhs) || isFunctionObject(lhs)) {
|
|
212
|
-
// if (!(Array.isArray(rhs) || isFunctionObject(rhs))) return false;
|
|
213
|
-
// if (nops(lhs) !== nops(rhs)) return false;
|
|
214
|
-
// if (!isEqual(head(lhs)!, head(rhs)!)) return false;
|
|
215
|
-
// const lhsTail = tail(lhs);
|
|
216
|
-
// const rhsTail = tail(rhs);
|
|
217
|
-
// for (let i = 0; i <= nops(lhs); i += 1)
|
|
218
|
-
// if (!isEqual(lhsTail[i], rhsTail[i])) return false;
|
|
219
|
-
// return true;
|
|
220
|
-
// }
|
|
221
|
-
// if (typeof lhs === 'number' || isNumberObject(lhs)) {
|
|
222
|
-
// if (!(typeof rhs === 'number' || isNumberObject(rhs))) return false;
|
|
223
|
-
// const mLhs = number(lhs);
|
|
224
|
-
// const mRhs = number(rhs);
|
|
225
|
-
// if (mLhs !== null) return mLhs === mRhs;
|
|
226
|
-
// return false;
|
|
227
|
-
// }
|
|
228
|
-
// return false;
|
|
229
|
-
// }
|
|
182
|
+
}
|
|
230
183
|
|
|
231
184
|
// This is the root of the `math-json` package (i.e. `math-json.js` and
|
|
232
|
-
const version = '0.
|
|
185
|
+
const version = '0.10.0';
|
|
233
186
|
|
|
234
|
-
export { applyRecursively,
|
|
187
|
+
export { applyRecursively, dictionary as getDictionary, stringValue as getStringValue, head, headName, isDictionaryObject, isFunctionObject, isStringObject, isSymbolObject, mapArgs, nops, op, symbol, version };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
2
|
-
function n(n){return null!==n&&"object"==typeof n&&"sym"in n}function t(n){return null!==n&&"object"==typeof n&&"str"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function u(n){return null!==n&&"object"==typeof n&&"dict"in n}function l(n){return null
|
|
1
|
+
/** MathJSON 0.10.0 */
|
|
2
|
+
function n(n){return null!==n&&"object"==typeof n&&"sym"in n}function t(n){return null!==n&&"object"==typeof n&&"str"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function u(n){return null!==n&&"object"==typeof n&&"dict"in n}function l(n){return null==n?null:"object"==typeof n&&"str"in n?n.str:"string"!=typeof n||n.length<2||"'"!==n[0]||"'"!==n[n.length-1]?null:n.substring(1,n.length-1)}function e(n){return null==n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function i(n){const t=e(n);return"string"==typeof t?t:""}function o(n){return null==n?null:Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):null}function f(n,t){return null==n?null:Array.isArray(n)?n[t]??null:r(n)?n.fn[t]??null:null}function c(n){return f(n,2)}function s(n){return null==n?0:Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function y(t){if(null==t)return null;if("string"==typeof t){if(/^[+\-\.0-9]/.test(t))return null;if(t.length>=2&&"'"===t[0]&&"'"===t[t.length-1])return null}const r=n(t)?t.sym:t;return"string"!=typeof r?null:r}function a(n){const t=e(n);if("KeyValuePair"===t||"Tuple"===t||"Pair"===t){const t=l(function(n){return f(n,1)}(n));return t?[t,c(n)??"Nothing"]:null}return null}function g(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=a(n);if(t)return{[t[0]]:t[1]};if("Dictionary"===e(n)){const t={};for(let r=1;r<s(n);r++){const u=a(f(n,r));u&&(t[u[0]]=u[1])}return t}return null}function p(n,t){const r=e(n);if(null!==r)return[t(r),...(o(n)??[]).map(t)];const u=g(n);if(null!==u){const n=Object.keys(u),r={};for(const l of n)r[l]=t(u[l]);return{dict:r}}return t(n)}function h(n,t){let u=null;if(Array.isArray(n)&&(u=n),r(n)&&(u=n.fn),null===u)return[];let l=1;const e=[];for(;l<u.length;)e.push(t(u[l])),l+=1;return e}const A="0.10.0";export{p as applyRecursively,g as getDictionary,l as getStringValue,e as head,i as headName,u as isDictionaryObject,r as isFunctionObject,t as isStringObject,n as isSymbolObject,h as mapArgs,s as nops,f as op,y as symbol,A as version};
|
package/dist/math-json.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** MathJSON 0.
|
|
2
|
-
var global,factory;global=this,factory=function(n){function t(n){return null!==n&&"object"==typeof n&&"sym"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function l(n){return null==n?null:"object"==typeof n&&"str"in n?n.str:"string"!=typeof n||n.length<2||"'"!==n[0]||"'"!==n[n.length-1]?null:n.substring(1,n.length-1)}function e(n){return null==n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function
|
|
1
|
+
/** MathJSON 0.10.0 */
|
|
2
|
+
var global,factory;global=this,factory=function(n){function t(n){return null!==n&&"object"==typeof n&&"sym"in n}function r(n){return null!==n&&"object"==typeof n&&"fn"in n}function l(n){return null==n?null:"object"==typeof n&&"str"in n?n.str:"string"!=typeof n||n.length<2||"'"!==n[0]||"'"!==n[n.length-1]?null:n.substring(1,n.length-1)}function e(n){return null==n?null:Array.isArray(n)?n[0]:r(n)?n.fn[0]:null}function u(n){return null==n?null:Array.isArray(n)?n.slice(1):r(n)?n.fn.slice(1):null}function o(n,t){var l,e;return null==n?null:Array.isArray(n)?null!==(l=n[t])&&void 0!==l?l:null:r(n)&&null!==(e=n.fn[t])&&void 0!==e?e:null}function i(n){return o(n,2)}function f(n){return null==n?0:Array.isArray(n)?Math.max(0,n.length-1):r(n)?Math.max(0,n.fn.length-1):0}function c(n){var t;const r=e(n);if("KeyValuePair"===r||"Tuple"===r||"Pair"===r){const r=l(function(n){return o(n,1)}(n));return r?[r,null!==(t=i(n))&&void 0!==t?t:"Nothing"]:null}return null}function s(n){if(null===n)return null;if("object"==typeof n&&"dict"in n)return n.dict;const t=c(n);if(t)return{[t[0]]:t[1]};if("Dictionary"===e(n)){const t={};for(let r=1;r<f(n);r++){const l=c(o(n,r));l&&(t[l[0]]=l[1])}return t}return null}n.applyRecursively=function(n,t){var r;const l=e(n);if(null!==l)return[t(l),...(null!==(r=u(n))&&void 0!==r?r:[]).map(t)];const o=s(n);if(null!==o){const n=Object.keys(o),r={};for(const l of n)r[l]=t(o[l]);return{dict:r}}return t(n)},n.getDictionary=s,n.getStringValue=l,n.head=e,n.headName=function(n){const t=e(n);return"string"==typeof t?t:""},n.isDictionaryObject=function(n){return null!==n&&"object"==typeof n&&"dict"in n},n.isFunctionObject=r,n.isStringObject=function(n){return null!==n&&"object"==typeof n&&"str"in n},n.isSymbolObject=t,n.mapArgs=function(n,t){let l=null;if(Array.isArray(n)&&(l=n),r(n)&&(l=n.fn),null===l)return[];let e=1;const u=[];for(;e<l.length;)u.push(t(l[e])),e+=1;return u},n.nops=f,n.op=o,n.symbol=function(n){if(null==n)return null;if("string"==typeof n){if(/^[+\-\.0-9]/.test(n))return null;if(n.length>=2&&"'"===n[0]&&"'"===n[n.length-1])return null}const r=t(n)?n.sym:n;return"string"!=typeof r?null:r},n.version="0.10.0",Object.defineProperty(n,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).MathJson={});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
|
|
3
3
|
export declare type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
4
|
export declare type SignalOrigin = {
|
|
@@ -25,10 +25,6 @@ export declare type Signal = {
|
|
|
25
25
|
export declare type ErrorSignal = Signal & {
|
|
26
26
|
severity: 'error';
|
|
27
27
|
};
|
|
28
|
-
export declare class CortexError extends Error {
|
|
29
|
-
constructor(errorSignal: Signal);
|
|
30
|
-
toString(): string;
|
|
31
|
-
}
|
|
32
28
|
export declare type WarningSignal = Signal & {
|
|
33
29
|
severity: 'warning';
|
|
34
30
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* 0.10.0 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Add an assumption, in the form of a predicate, for example:
|
|
4
4
|
*
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
* of these are stored directly in the current scope's symbols dictionary
|
|
14
14
|
* (and an entry for the symbol is created if necessary).
|
|
15
15
|
*
|
|
16
|
+
* New assumptions can 'refine' previous assumptions, that is they are valid
|
|
17
|
+
* if they don't contradict previous assumptions. To set new assumptions
|
|
18
|
+
* that contradict previous ones, you must first `forget` about any symbols
|
|
19
|
+
* in the new assumption.
|
|
20
|
+
*
|
|
16
21
|
* Predicates that involve multiple symbols are simplified (for example
|
|
17
22
|
* `x + y = 5` becomes `x + y - 5 = 0`, then stored in the `assumptions` of the
|
|
18
23
|
* current context).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import
|
|
1
|
+
/* 0.10.0 */
|
|
2
|
+
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
-
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions,
|
|
4
|
+
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
|
|
5
5
|
/**
|
|
6
6
|
* AbstractBoxedExpression
|
|
7
7
|
*/
|
|
@@ -13,7 +13,7 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
13
13
|
abstract set isCanonical(_val: boolean);
|
|
14
14
|
abstract isSame(rhs: BoxedExpression): boolean;
|
|
15
15
|
abstract isEqual(rhs: BoxedExpression): boolean;
|
|
16
|
-
abstract match(rhs: BoxedExpression, options?:
|
|
16
|
+
abstract match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
17
17
|
readonly engine: IComputeEngine;
|
|
18
18
|
/** Verbatim LaTeX, obtained from a source, i.e. from parsing, not generated
|
|
19
19
|
* synthetically
|
|
@@ -30,6 +30,7 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
30
30
|
[Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
|
|
31
31
|
/** Called by `JSON.stringify()` when serializing to json */
|
|
32
32
|
toJSON(): Expression;
|
|
33
|
+
get scope(): RuntimeScope | null;
|
|
33
34
|
/** Object.is() */
|
|
34
35
|
is(rhs: any): boolean;
|
|
35
36
|
get latex(): LatexString;
|
|
@@ -48,13 +49,16 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
48
49
|
get op3(): BoxedExpression;
|
|
49
50
|
get isValid(): boolean;
|
|
50
51
|
get isPure(): boolean;
|
|
52
|
+
get isExact(): boolean;
|
|
51
53
|
/** For a symbol, true if the symbol is a free variable (no value) */
|
|
52
54
|
get isFree(): boolean;
|
|
53
55
|
/** For a symbol, true if the symbol is a constant (unchangeable value) */
|
|
54
56
|
get isConstant(): boolean;
|
|
55
57
|
get canonical(): BoxedExpression;
|
|
56
58
|
apply(_fn: (x: BoxedExpression) => SemiBoxedExpression, _head?: string): BoxedExpression;
|
|
57
|
-
subs(_sub: Substitution
|
|
59
|
+
subs(_sub: Substitution, options?: {
|
|
60
|
+
canonical: boolean;
|
|
61
|
+
}): BoxedExpression;
|
|
58
62
|
solve(_vars: Iterable<string>): null | BoxedExpression[];
|
|
59
63
|
replace(_rules: BoxedRuleSet): null | BoxedExpression;
|
|
60
64
|
has(_v: string | string[]): boolean;
|
|
@@ -69,13 +73,7 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
69
73
|
get isOdd(): boolean | undefined;
|
|
70
74
|
get isPrime(): boolean | undefined;
|
|
71
75
|
get isComposite(): boolean | undefined;
|
|
72
|
-
get
|
|
73
|
-
get rationalValue(): [numer: number, denom: number] | [null, null];
|
|
74
|
-
get decimalValue(): Decimal | null;
|
|
75
|
-
get complexValue(): Complex | null;
|
|
76
|
-
get asFloat(): number | null;
|
|
77
|
-
get asSmallInteger(): number | null;
|
|
78
|
-
get asRational(): [number, number] | [null, null];
|
|
76
|
+
get numericValue(): number | Decimal | Complex | Rational | null;
|
|
79
77
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
80
78
|
isLess(_rhs: BoxedExpression): boolean | undefined;
|
|
81
79
|
isLessEqual(_rhs: BoxedExpression): boolean | undefined;
|
|
@@ -88,7 +86,6 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
88
86
|
isCompatible(_dom: BoxedDomain | DomainLiteral, _kind?: DomainCompatibility): boolean;
|
|
89
87
|
get description(): string[] | undefined;
|
|
90
88
|
get url(): string | undefined;
|
|
91
|
-
get isLiteral(): boolean;
|
|
92
89
|
get wikidata(): string | undefined;
|
|
93
90
|
set wikidata(val: string | undefined);
|
|
94
91
|
get complexity(): number | undefined;
|
|
@@ -103,8 +100,6 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
103
100
|
hasKey(_key: string): boolean;
|
|
104
101
|
get value(): BoxedExpression | undefined;
|
|
105
102
|
set value(_value: BoxedExpression | number | undefined);
|
|
106
|
-
get numericValue(): BoxedExpression | undefined;
|
|
107
|
-
isSubdomainOf(_d: BoxedExpression | string): undefined | boolean;
|
|
108
103
|
get domain(): BoxedDomain;
|
|
109
104
|
set domain(_domain: BoxedDomain);
|
|
110
105
|
get explicitDomain(): BoxedDomain | undefined;
|
|
@@ -1,7 +1,74 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
|
-
import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata } from '../public';
|
|
3
|
+
import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, Rational } from '../public';
|
|
4
4
|
import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
5
|
+
/**
|
|
6
|
+
* **Theory of Operations**
|
|
7
|
+
*
|
|
8
|
+
* 1/ Boxing does not depend on the numeric mode. The numeric mode could be
|
|
9
|
+
* changed later, but the previously boxed numbers could not be retroactively
|
|
10
|
+
* upgraded.
|
|
11
|
+
*
|
|
12
|
+
* The `numericMode` is taken into account only during evaluation.
|
|
13
|
+
*
|
|
14
|
+
* Therefore, a boxed expression may contain a mix of number representations.
|
|
15
|
+
*
|
|
16
|
+
* 2/ The result of boxing is canonical by default.
|
|
17
|
+
*
|
|
18
|
+
* This is the most common need (i.e. as soon as you want to evaluate an
|
|
19
|
+
* expression you need a canonical expression). Creating a boxed expression
|
|
20
|
+
* which is canonical from the start avoid going through an intermediary step
|
|
21
|
+
* with a non-canonical expression.
|
|
22
|
+
*
|
|
23
|
+
* 3/ When implementing an `evaluate()`:
|
|
24
|
+
* - if `bignumPreferred()` all operations should be done in bignum and complex,
|
|
25
|
+
* otherwise, they should all be done in machine numbers and complex.
|
|
26
|
+
* - if not `complexAllowed()`, return `NaN` if a complex value is encountered
|
|
27
|
+
* - if a `Sqrt` (of a rational) is encountered, preserve it
|
|
28
|
+
* - if a `hold` constant is encountered, preserve it
|
|
29
|
+
* - if a rational is encountered, preserve it
|
|
30
|
+
* - if one of the arguments is not exact, return an approximation
|
|
31
|
+
*
|
|
32
|
+
* EXACT
|
|
33
|
+
* - 2 + 5 -> 7
|
|
34
|
+
* - 2 + 5/7 -> 19/7
|
|
35
|
+
* - 2 + √2 -> 2 + √2
|
|
36
|
+
* - 2 + √(5/7) -> 2 + √(5/7)
|
|
37
|
+
* - 5/7 + 9/11 -> 118/77
|
|
38
|
+
* - 5/7 + √2 -> 5/7 + √2
|
|
39
|
+
* - 10/14 + √(18/9) -> 5/7 + √2
|
|
40
|
+
* - √2 + √5 -> √2 + √5
|
|
41
|
+
* - √2 + √2 -> 2√2
|
|
42
|
+
* - sin(2) -> sin(2)
|
|
43
|
+
* - sin(pi/3) -> √3/2
|
|
44
|
+
*
|
|
45
|
+
* APPROXIMATE
|
|
46
|
+
* - 2 + 2.1 -> 4.1
|
|
47
|
+
* - 2 + √2.1 -> 3.44914
|
|
48
|
+
* - 5/7 + √2.1 -> 2.16342
|
|
49
|
+
* - sin(2) + √2.1 -> 2.35844
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Return a boxed number representing `num`.
|
|
53
|
+
*
|
|
54
|
+
* Note: `boxNumber()` should only be called from `ce.number()` in order to
|
|
55
|
+
* benefit from number expression caching.
|
|
56
|
+
*/
|
|
57
|
+
export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | number | string | Complex | Decimal | Rational, options?: {
|
|
58
|
+
metadata?: Metadata;
|
|
59
|
+
canonical?: boolean;
|
|
60
|
+
}): BoxedExpression | null;
|
|
61
|
+
/**
|
|
62
|
+
* Given a head and a set of arguments, return a boxed function expression.
|
|
63
|
+
*
|
|
64
|
+
* If available, preserve LaTeX and wikidata metadata in the boxed expression.
|
|
65
|
+
*
|
|
66
|
+
* Note that `boxFunction()` should only be called from `ce.fn()` or `box()`
|
|
67
|
+
*/
|
|
68
|
+
export declare function boxFunction(ce: IComputeEngine, head: string, ops: SemiBoxedExpression[], options: {
|
|
69
|
+
metadata?: Metadata;
|
|
70
|
+
canonical?: boolean;
|
|
71
|
+
}): BoxedExpression;
|
|
5
72
|
/**
|
|
6
73
|
* Notes about the boxed form:
|
|
7
74
|
*
|
|
@@ -17,6 +84,7 @@ import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
|
17
84
|
* `Add`/`Multiply` expression avoids this ambiguity.
|
|
18
85
|
*
|
|
19
86
|
* [3] An expression with a `Rational` head is converted to a rational number.
|
|
87
|
+
* if possible, to a `Divide` otherwise.
|
|
20
88
|
*
|
|
21
89
|
* [4] A `Negate` function applied to a number literal is converted to a number.
|
|
22
90
|
*
|
|
@@ -24,19 +92,9 @@ import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
|
24
92
|
* Note that `Negate` is only distributed over addition. In practice, having
|
|
25
93
|
* `Negate` factored on multiply/divide is more useful to detect patterns.
|
|
26
94
|
*
|
|
27
|
-
* Note that the `box()` function should only be called from `
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
export declare function box(ce: IComputeEngine, expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression): BoxedExpression;
|
|
31
|
-
/**
|
|
32
|
-
* Return a boxed number representing `num`.
|
|
33
|
-
*
|
|
34
|
-
* This function tries to avoid creating a boxed number if `num` corresponds
|
|
35
|
-
* to a common value for which we have a shared instance (-1, 0, NaN, etc...)
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* Note that `boxNumber()` should only be called from `ComputeEngine`
|
|
95
|
+
* Note that the `box()` function should only be called from `ce.box()`
|
|
39
96
|
*
|
|
40
|
-
* The result may not be canonical
|
|
41
97
|
*/
|
|
42
|
-
export declare function
|
|
98
|
+
export declare function box(ce: IComputeEngine, expr: null | undefined | Decimal | Complex | Rational | SemiBoxedExpression, options?: {
|
|
99
|
+
canonical?: boolean;
|
|
100
|
+
}): BoxedExpression;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata,
|
|
1
|
+
/* 0.10.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedDictionary
|
|
@@ -9,7 +9,10 @@ export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
|
9
9
|
private _isCanonical;
|
|
10
10
|
constructor(ce: IComputeEngine, dict: {
|
|
11
11
|
[key: string]: SemiBoxedExpression;
|
|
12
|
-
},
|
|
12
|
+
}, options?: {
|
|
13
|
+
canonical?: boolean;
|
|
14
|
+
metadata?: Metadata;
|
|
15
|
+
});
|
|
13
16
|
unbind(): undefined;
|
|
14
17
|
get hash(): number;
|
|
15
18
|
get complexity(): number;
|
|
@@ -24,7 +27,7 @@ export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
|
24
27
|
get json(): Expression;
|
|
25
28
|
/** Structural equality */
|
|
26
29
|
isSame(rhs: BoxedExpression): boolean;
|
|
27
|
-
match(rhs: BoxedExpression, _options?:
|
|
30
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
28
31
|
/** Mathematical equality */
|
|
29
32
|
isEqual(rhs: BoxedExpression): boolean;
|
|
30
33
|
apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
|
|
@@ -35,5 +38,7 @@ export declare class BoxedDictionary extends AbstractBoxedExpression {
|
|
|
35
38
|
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
36
39
|
N(options?: NOptions): BoxedExpression;
|
|
37
40
|
replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
|
|
38
|
-
subs(sub: Substitution
|
|
41
|
+
subs(sub: Substitution, options?: {
|
|
42
|
+
canonical: boolean;
|
|
43
|
+
}): BoxedExpression;
|
|
39
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { BoxedDomain, BoxedExpression, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata,
|
|
1
|
+
/* 0.10.0 */
|
|
2
|
+
import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
5
5
|
* A `_BoxedDomain` is a wrapper around a boxed, canonical, domain expression.
|
|
@@ -31,7 +31,7 @@ export declare class _BoxedDomain extends AbstractBoxedExpression implements Box
|
|
|
31
31
|
isSame(rhs: BoxedExpression): boolean;
|
|
32
32
|
is(rhs: any): boolean;
|
|
33
33
|
isCompatible(dom: BoxedDomain | DomainLiteral, compatibility?: DomainCompatibility): boolean;
|
|
34
|
-
match(rhs: BoxedExpression, _options?:
|
|
34
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
35
35
|
get head(): string;
|
|
36
36
|
get domain(): BoxedDomain;
|
|
37
37
|
get isNothing(): boolean;
|
|
@@ -46,6 +46,5 @@ export declare class _BoxedDomain extends AbstractBoxedExpression implements Box
|
|
|
46
46
|
export declare function boxDomain(ce: IComputeEngine, dom: BoxedDomain | DomainExpression, metadata?: Metadata): BoxedDomain;
|
|
47
47
|
/** Validate that `expr` is a Domain */
|
|
48
48
|
export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
|
|
49
|
-
export declare function isSubdomainOf(lhs: DomainExpression<BoxedExpression>, rhs: DomainExpression<BoxedExpression>): boolean;
|
|
50
49
|
/** Return the ancestor domain that is shared by both `a` and `b` */
|
|
51
50
|
export declare function sharedAncestorDomain(a: BoxedDomain, b: BoxedDomain): BoxedDomain;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare function makeFunctionDefinition(engine: IComputeEngine, def: FunctionDefinition): BoxedFunctionDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
-
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata,
|
|
3
|
+
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedFunction
|
|
6
6
|
*/
|
|
@@ -27,9 +27,9 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
27
27
|
get hash(): number;
|
|
28
28
|
get isCanonical(): boolean;
|
|
29
29
|
set isCanonical(val: boolean);
|
|
30
|
-
get isLiteral(): boolean;
|
|
31
30
|
get isPure(): boolean;
|
|
32
31
|
get json(): Expression;
|
|
32
|
+
get scope(): RuntimeScope | null;
|
|
33
33
|
get head(): string | BoxedExpression;
|
|
34
34
|
get ops(): BoxedExpression[];
|
|
35
35
|
get nops(): number;
|
|
@@ -39,13 +39,14 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
39
39
|
get isValid(): boolean;
|
|
40
40
|
get canonical(): BoxedExpression;
|
|
41
41
|
map<T = BoxedExpression>(fn: (x: BoxedExpression) => T): IterableIterator<T>;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
subs(sub: Substitution, options?: {
|
|
43
|
+
canonical?: boolean;
|
|
44
|
+
}): BoxedExpression;
|
|
44
45
|
replace(rules: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
|
|
45
46
|
has(x: string | string[]): boolean;
|
|
46
47
|
/** `isSame` is structural/symbolic equality */
|
|
47
48
|
isSame(rhs: BoxedExpression): boolean;
|
|
48
|
-
match(rhs: BoxedExpression, options?:
|
|
49
|
+
match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
49
50
|
unbind(): void;
|
|
50
51
|
get wikidata(): string | undefined;
|
|
51
52
|
get description(): string[] | undefined;
|
|
@@ -54,8 +55,6 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
54
55
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
55
56
|
bind(_scope: RuntimeScope | null): void;
|
|
56
57
|
get value(): BoxedExpression | undefined;
|
|
57
|
-
get numericValue(): BoxedExpression | undefined;
|
|
58
|
-
get domain(): BoxedDomain;
|
|
59
58
|
/** `isEqual` is mathematical equality */
|
|
60
59
|
isEqual(rhs: BoxedExpression): boolean;
|
|
61
60
|
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
@@ -79,16 +78,18 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
79
78
|
get isComplex(): boolean | undefined;
|
|
80
79
|
get isImaginary(): boolean | undefined;
|
|
81
80
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
81
|
+
get domain(): BoxedDomain;
|
|
82
82
|
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
83
83
|
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
84
84
|
N(options?: NOptions): BoxedExpression;
|
|
85
|
-
solve(
|
|
85
|
+
solve(vars: string[]): null | BoxedExpression[];
|
|
86
86
|
}
|
|
87
|
-
export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops: SemiBoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
88
|
+
/** Apply arguments to an expression. If the expression is a lambda expression
|
|
89
|
+
* it's wildcard arguments are substituted before being evaluated. Otherwise
|
|
90
|
+
* the expression is just evaluated.
|
|
91
|
+
*/
|
|
92
|
+
export declare function apply(fn: BoxedExpression, args: BoxedExpression[]): BoxedExpression;
|
|
92
93
|
/** Apply the function `f` to elements of `xs`, except to the elements
|
|
93
94
|
* described by `skip`:
|
|
94
95
|
* - `all`: don't apply f to any elements
|
|
@@ -102,4 +103,4 @@ export declare function lambda(ce: IComputeEngine, fn: BoxedLambdaExpression, ar
|
|
|
102
103
|
*
|
|
103
104
|
* If `f` returns `null`, the element is not added to the result
|
|
104
105
|
*/
|
|
105
|
-
export declare function holdMap(
|
|
106
|
+
export declare function holdMap(xs: BoxedExpression[], skip: 'all' | 'none' | 'first' | 'rest' | 'last' | 'most', associativeHead: string, f: (x: BoxedExpression) => BoxedExpression | null): BoxedExpression[];
|