Doc: changed fraction symbol and introduced binary operators
This commit is contained in:
+34
-31
@@ -127,22 +127,22 @@ dev-expr -- Expressions calculator v1.10.0(build 14),2024/06/17 (celestino.amoro
|
||||
9.5
|
||||
>>> 0xFD + 0b1 + 0o1 <1>
|
||||
255
|
||||
>>> 1|2 + 2|3 <2>
|
||||
7|6
|
||||
>>> 1:2 + 2:3 <2>
|
||||
7:6
|
||||
>>> ml <3>
|
||||
>>> 1|2 + 2|3
|
||||
>>> 1:2 + 2:3
|
||||
7
|
||||
-
|
||||
6
|
||||
>>> 4+2 but 5|2+0.5 <4>
|
||||
>>> 4+2 but 5:2+0.5 <4>
|
||||
3
|
||||
>>> 4+2; 5|2+0.5 <5>
|
||||
>>> 4+2; 5:2+0.5 <5>
|
||||
3
|
||||
>>>
|
||||
----
|
||||
|
||||
<1> Number bases: 0x = _hexadecimal_, 0o = _octal_, 0b = _binary_.
|
||||
<2> Fractions: _numerator_ | _denominator_.
|
||||
<2> Fractions: _numerator_ : _denominator_.
|
||||
<3> Activate multi-line output of fractions.
|
||||
<4> But operator, see <<_but_operator>>.
|
||||
<5> Multi-expression: the same result of the previous single expression but this it is obtained with two separated calculations.
|
||||
@@ -236,11 +236,11 @@ _dec-seq_ = _see-integer-literal-syntax_
|
||||
|===
|
||||
|
||||
==== Fractions
|
||||
_Expr_ also supports fractions. Fraction literals are made with two integers separated by a vertical bar `|`.
|
||||
_Expr_ also supports fractions. Fraction literals are made with two integers separated by a colon character `:`.
|
||||
|
||||
.Fraction literal syntax
|
||||
====
|
||||
*_fraction_* = [__sign__] (_num-den-spec_ | _float-spec_) +
|
||||
*_fraction_* = [__sign__] (_num-den-spec_ "**:**" _float-spec_) +
|
||||
_sign_ = "**+**" | "**-**" +
|
||||
_num-den-spec_ = _digit-seq_ "**|**" _digit-seq_ +
|
||||
_float-spec_ = _dec-seq_ "**.**" [_dec-seq_] "**(**" _dec-seq_ "**)**" +
|
||||
@@ -249,44 +249,44 @@ _digit-seq_ = _see-integer-literal-syntax_
|
||||
====
|
||||
|
||||
.Examples
|
||||
`>>>` [blue]`1 | 2` +
|
||||
[green]`1|2`
|
||||
`>>>` [blue]`1 : 2` +
|
||||
[green]`1:2`
|
||||
|
||||
`>>>` [blue]`4|6` [gray]_// Fractions are always reduced to their lowest terms_ +
|
||||
[green]`2|3`
|
||||
`>>>` [blue]`4:6` [gray]_// Fractions are always reduced to their lowest terms_ +
|
||||
[green]`2:3`
|
||||
|
||||
`>>>` [blue]`1|2 + 2|3` +
|
||||
[green]`7|6`
|
||||
`>>>` [blue]`1:2 + 2:3` +
|
||||
[green]`7:6`
|
||||
|
||||
`>>>` [blue]`1|2 * 2|3` +
|
||||
[green]`1|3`
|
||||
`>>>` [blue]`1:2 * 2:3` +
|
||||
[green]`1:3`
|
||||
|
||||
`>>>` [blue]`1|2 / 1|3` +
|
||||
[green]`3|2`
|
||||
`>>>` [blue]`1:2 / 1:3` +
|
||||
[green]`3:2`
|
||||
|
||||
`>>>` [blue]`1|2 ./ 1|3` [gray]_// Force decimal division_ +
|
||||
`>>>` [blue]`1:2 ./ 1:3` [gray]_// Force decimal division_ +
|
||||
[green]`1.5`
|
||||
|
||||
`>>>` [blue]`-1|2` +
|
||||
[green]`-1|2`
|
||||
`>>>` [blue]`-1:2` +
|
||||
[green]`-1:2`
|
||||
|
||||
`>>>` [blue]`1|-2` [gray]_// Invalid sign specification_ +
|
||||
[red]_Eval Error: [1:3] infix operator "|" requires two non-nil operands, got 1_
|
||||
`>>>` [blue]`1:-2` [gray]_// Invalid sign specification_ +
|
||||
[red]_Eval Error: [1:3] infix operator ":" requires two non-nil operands, got 1_
|
||||
|
||||
`>>>` [blue]`1|(-2)` +
|
||||
[green]`-1|2`
|
||||
`>>>` [blue]`1:(-2)` +
|
||||
[green]`-1:2`
|
||||
|
||||
|
||||
Fractions can be used together with integers and floats in expressions.
|
||||
|
||||
.Examples
|
||||
`>>>` [blue]`1|2 + 5` +
|
||||
[green]`11|2`
|
||||
`>>>` [blue]`1:2 + 5` +
|
||||
[green]`11:2`
|
||||
|
||||
`>>>` [blue]`4 - 1|2` +
|
||||
[green]`7|2`
|
||||
`>>>` [blue]`4 - 1:2` +
|
||||
[green]`7:2`
|
||||
|
||||
`>>>` [blue]`1.0 + 1|2` +
|
||||
`>>>` [blue]`1.0 + 1:2` +
|
||||
[green]`1.5`
|
||||
|
||||
|
||||
@@ -753,7 +753,7 @@ The table below shows all supported operators by decreasing priorities.
|
||||
| [blue]`#` | _Prefix_ | _Size-of_ | `#` _iterator_ -> _integer_
|
||||
.2+|*SELECT*| [blue]`? : ::` | _Multi-Infix_ | _Case-Selector_ | _any-expr_ `?` _case-list_ _case-expr_ `:` _case-list_ _case-expr_ ... `::` _default-expr_ -> _any_
|
||||
| [blue]`? : ::` | _Multi-Infix_ | _Index-Selector_ | _int-expr_ `?` _case-expr_ `:` _case-expr_ ... `::` _default-expr_ -> _any_
|
||||
.1+|*FRACT*| [blue]`\|` | _Infix_ | _Fraction_ | _integer_ `\|` _integer_ -> _fraction_
|
||||
.1+|*FRACT*| [blue]`:` | _Infix_ | _Fraction_ | _integer_ `:` _integer_ -> _fraction_
|
||||
.5+|*PROD*| [blue]`*` | _Infix_ | _Product_ | _number_ `*` _number_ -> _number_
|
||||
| [blue]`*` | _Infix_ | _String-repeat_ | _string_ `*` _integer_ -> _string_
|
||||
| [blue]`/` | _Infix_ | _Division_ | _number_ `/` _number_ -> _number_
|
||||
@@ -765,6 +765,9 @@ The table below shows all supported operators by decreasing priorities.
|
||||
| [blue]`+` | _Infix_ | _Dict-join_ | _dict_ `+` _dict_ -> _dict_
|
||||
| [blue]`-` | _Infix_ | _Subtraction_ | _number_ `-` _number_ -> _number_
|
||||
| [blue]`-` | _Infix_ | _List-difference_ | _list_ `-` _list_ -> _list_
|
||||
.3+|*BINARY*| [blue]`&` | _Infix_ | _Binary And_ | _number_ `&` _number_ -> _number_
|
||||
| [blue]`\|` | _Infix_ | _Binary Or_ | _number_ `\|` _number_ -> _number_
|
||||
| [blue]`~` | _Prefix_ | _Binary Not_ | `~` _number_ -> _number_
|
||||
.8+|*RELATION*| [blue]`<` | _Infix_ | _Less_ | _comparable_ `<` _comparable_ -> _boolean_
|
||||
| [blue]`\<=` | _Infix_ | _less-equal_ | _comparable_ `\<=` _comparable_ -> _boolean_
|
||||
| [blue]`>` | _Infix_ | _Greater_ | _comparable_ `>` _comparable_ -> _boolean_
|
||||
|
||||
Reference in New Issue
Block a user