@@ -14,13 +14,15 @@ the lower level syntax of math.js. Differences are:
1414
1515- No need to prefix functions and constants with the ` math.* ` namespace,
1616 you can just enter ` sin(pi / 4) ` .
17- - Matrix indexes are one-based instead of zero-based.
17+ - By default, bracket notation ` [1, 2, 3] ` produces a Matrix object rather
18+ than an Array; and an Array can be written with list notation, as ` (1, 2, 3) ` .
19+ - Matrix and Array indexes are one-based instead of zero-based.
1820- There are index and range operators which allow more conveniently getting
1921 and setting matrix indexes, like ` A[2:4, 1] ` .
2022- Both indexes and ranges and have the upper-bound included.
2123- There is a differing syntax for defining functions. Example: ` f(x) = x^2 ` .
2224- There are custom operators like ` x + y ` instead of ` add(x, y) ` .
23- - Some operators are different. For example ` ^ ` is used for exponentiation,
25+ - Some operators are different. For example, ` ^ ` is used for exponentiation,
2426 not bitwise xor.
2527- Implicit multiplication, like ` 2 pi ` , is supported and has special rules.
2628- Relational operators (` < ` , ` > ` , ` <= ` , ` >= ` , ` == ` , and ` != ` ) are chained, so the expression ` 5 < x < 10 ` is equivalent to ` 5 < x and x < 10 ` .
@@ -58,7 +60,8 @@ Functions below.
5860Operator | Name | Syntax | Associativity | Example | Result
5961----------- |-----------------------------|-------------| ------------- |-----------------------| ---------------
6062` ( ` , ` ) ` | Grouping | ` (x) ` | None | ` 2 * (3 + 4) ` | ` 14 `
61- ` [ ` , ` ] ` | Matrix, Index | ` [...] ` | None | ` [[1,2],[3,4]] ` | ` [[1,2],[3,4]] `
63+ | Array, function arguments | ` (x, y,...) ` | None | ` ((), (1,), (1,2)) ` | ` [[], [1], [1,2]] `
64+ ` [ ` , ` ] ` | Matrix, Index | ` [...] ` | None | ` [[1,2],[3,4]] ` | ` matrix([[1,2],[3,4]]) `
6265` { ` , ` } ` | Object | ` {...} ` | None | ` {a: 1, b: 2} ` | ` {a: 1, b: 2} `
6366` , ` | Parameter separator | ` x, y ` | Left to right | ` max(2, 1, 5) ` | ` 5 `
6467` . ` | Property accessor | ` obj.prop ` | Left to right | ` obj={a: 12}; obj.a ` | ` 12 `
@@ -112,7 +115,7 @@ The operators have the following precedence, from highest to lowest:
112115
113116Operators | Description
114117--------------------------------- | --------------------
115- ` (...) ` <br >` [...] ` <br >` {...} ` | Grouping<br >Matrix<br >Object
118+ ` (...) ` <br >` [...] ` <br >` {...} ` | Grouping/Array <br >Matrix<br >Object
116119` x(...) ` <br >` x[...] ` <br >` obj.prop ` <br >` : ` | Function call<br >Matrix index<br >Property accessor<br >Key/value separator
117120` ' ` | Matrix transpose
118121` ! ` | Factorial
0 commit comments