diff --git a/doc/Expr.adoc b/doc/Expr.adoc index d5700bb..9bf5ead 100644 --- a/doc/Expr.adoc +++ b/doc/Expr.adoc @@ -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_ diff --git a/doc/Expr.html b/doc/Expr.html index 9df2ac6..d52e783 100644 --- a/doc/Expr.html +++ b/doc/Expr.html @@ -474,6 +474,16 @@ pre.rouge .gh { color: #b8bb26; font-weight: bold; } +pre.rouge .ge { + font-style: italic; +} +pre.rouge .ges { + font-weight: bold; + font-style: italic; +} +pre.rouge .gs { + font-weight: bold; +} pre.rouge .k, pre.rouge .kn, pre.rouge .kp, pre.rouge .kr, pre.rouge .kv { color: #fb4934; } @@ -745,16 +755,16 @@ dev-expr -- Expressions calculator v1.10.0>>> 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 >>> @@ -767,7 +777,7 @@ dev-expr -- Expressions calculator v1.10.02 -Fractions: numerator | denominator. +Fractions: numerator : denominator. 3 @@ -981,13 +991,13 @@ dev-expr -- Expressions calculator v1.10.0

2.1.3. 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 :.

Example 3. 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 ")"
@@ -998,55 +1008,55 @@ dev-expr -- Expressions calculator v1.10.0

Examples
-

>>> 1 | 2
-1|2

+

>>> 1 : 2
+1:2

-

>>> 4|6 // Fractions are always reduced to their lowest terms
-2|3

+

>>> 4:6 // Fractions are always reduced to their lowest terms
+2:3

-

>>> 1|2 + 2|3
-7|6

+

>>> 1:2 + 2:3
+7:6

-

>>> 1|2 * 2|3
-1|3

+

>>> 1:2 * 2:3
+1:3

-

>>> 1|2 / 1|3
-3|2

+

>>> 1:2 / 1:3
+3:2

-

>>> 1|2 ./ 1|3 // Force decimal division
+

>>> 1:2 ./ 1:3 // Force decimal division
1.5

-

>>> -1|2
--1|2

+

>>> -1:2
+-1:2

-

>>> 1|-2 // Invalid sign specification
-Eval Error: [1:3] infix operator "|" requires two non-nil operands, got 1

+

>>> 1:-2 // Invalid sign specification
+Eval Error: [1:3] infix operator ":" requires two non-nil operands, got 1

-

>>> 1|(-2)
--1|2

+

>>> 1:(-2)
+-1:2

Fractions can be used together with integers and floats in expressions.

Examples
-

>>> 1|2 + 5
-11|2

+

>>> 1:2 + 5
+11:2

-

>>> 4 - 1|2
-7|2

+

>>> 4 - 1:2
+7:2

-

>>> 1.0 + 1|2
+

>>> 1.0 + 1:2
1.5

@@ -1992,10 +2002,10 @@ These operators have a high priority, in particular higher than the operator

FRACT

-

|

+

:

Infix

Fraction

-

integer | integerfraction

+

integer : integerfraction

PROD

@@ -2066,6 +2076,25 @@ These operators have a high priority, in particular higher than the operator

list - listlist

+

BINARY

+

&

+

Infix

+

Binary And

+

number & numbernumber

+ + +

|

+

Infix

+

Binary Or

+

number | numbernumber

+ + +

~

+

Prefix

+

Binary Not

+

~ numbernumber

+ +

RELATION

<

Infix

@@ -2432,7 +2461,7 @@ g(@p):any{}`