Doc: more details on some operators

This commit is contained in:
Celestino Amoroso 2024-05-20 06:59:49 +02:00
parent 7c8dbb0ac7
commit f22b5a6f0b
2 changed files with 205 additions and 65 deletions

View File

@ -22,7 +22,7 @@ Expressions calculator
toc::[]
#TODO: Work in progress (last update on 2024/05/17, 15:47 p.m.)#
#TODO: Work in progress (last update on 2024/05/20, 06:58 a.m.)#
== Expr
_Expr_ is a GO package capable of analysing, interpreting and calculating expressions.
@ -266,10 +266,10 @@ Some arithmetic operators can also be used with strings.
|===
| Symbol | Operation | Description | Examples
| [blue]`+` | _concatenation_ | Join two strings or two _stringable_ values | [blue]`"one" + "two"` _["onetwo"]_ +
[blue]`"one" + 2` _["one2"]_
| [blue]`+` | _concatenation_ | Join two strings or two _stringable_ values | [blue]`"one" + "two"` -> _"onetwo"_ +
[blue]`"one" + 2` -> _"one2"_
| [blue]`*` | _repeat_ | Make _n_ copy of a string | [blue]`"one" * 2` _["oneone"]_
| [blue]`*` | _repeat_ | Make _n_ copy of a string | [blue]`"one" * 2` -> _"oneone"_
|===
The items of strings can be accessed using the dot `.` operator.
@ -280,15 +280,15 @@ _item_ = _string-expr_ "**.**" _integer-expr_
====
.String examples
`>>>` [blue]`s="abc"` [gray]_assign the string to variable s_ +
`>>>` [blue]`s="abc"` [gray]_// assign the string to variable s_ +
[green]`abc` +
`>>>` [blue]`s.1` [gray]_char at position 1 (starting from 0)_ +
`>>>` [blue]`s.1` [gray]_// char at position 1 (starting from 0)_ +
[green]`b` +
`>>>` [blue]`s.(-1)` [gray]_char at position -1, the rightmost one_ +
`>>>` [blue]`s.(-1)` [gray]_// char at position -1, the rightmost one_ +
[green]`c` +
`>>>` [blue]`\#s` [gray]_number of chars_ +
`>>>` [blue]`\#s` [gray]_// number of chars_ +
[gren]`3` +
`>>>` [blue]`#"abc"` [gray]_number of chars_ +
`>>>` [blue]`#"abc"` [gray]_// number of chars_ +
[green]`3`
@ -371,13 +371,18 @@ _non-empty-list_ = "**[**" _any-value_ {"**,**" _any-value} "**]**" +
| [blue]`+` | _Join_ | Joins two lists | [blue]`[1,2] + [3]` -> _[1,2,3]_
| [blue]`-` | _Difference_ | Left list without elements in the right list | [blue]`[1,2,3] - [2]` -> _[1,3]_
| [blue]`>>` | _Front insertion_ | Insert an item in front | [blue]`0 >> [1,2]` -> _[0,1,2]_
| [blue]`<<` | _Back insertion_ | Insert an item at end | [blue]`[1,2] << 3` -> _[1,2,3]_
| [blue]`.` | _List item_ | Item at given position | [blue]`[1,2.3].1` -> _2_
| [blue]`in` | _Item in list_ | True if item is in list | [blue]`2 in [1,2,3]` -> _true_ +
[blue]`6 in [1,2,3]` -> _false_
|===
The items of array can be accessed using the dot `.` operator.
.Item access syntax
====
_item_ = _list-expr_ "**.**" _list-expr_
_item_ = _list-expr_ "**.**" _integer-expr_
====
.Items of list
@ -394,14 +399,16 @@ _item_ = _list-expr_ "**.**" _list-expr_
`>>>` [blue]`list.(10)` +
[red]`Eval Error: [1:9] index 10 out of bounds` +
`>>>` [blue]`#list` +
[green]`3`
[green]`3` +
`>>>` [blue]`index=2; ["a", "b", "c", "d"].index` +
[green]`c`
=== Dictionaries
WARNING: Support for dictionaries is still ongoing.
The _dictionary_, or _dict_, data-type is set of pairs _key/value_. It is also known as _map_ or _associative array_.
The _dictionary_, or _dict_, data-type is set of pairs _key/value_. It is also known as _map_ or _associative array_. Dictionary literals are sequences of pairs separated by comma `,`; sequences are enclosed between brace brackets.
Dictionary literals are sequences of pairs separated by comma [blue]`,` enclosed between brace brackets.
.Dict literal syntax
====
@ -412,11 +419,27 @@ _non-empty-dict_ = "**{**" _key-scalar_ "**:**" _any-value_ {"**,**" _key-scalar
.Examples
`>>>` [blue]`{1:"one", 2:"two"}` +
[green]`{1: "one", 2: "two"}` +
`>>>` [blue]`{"one":1, "two": 2}` +
`>>>` [blue]`{"sum":1+2+3, "prod":1*2*3}`
[green]`{"one": 1, "two": 2}` +
`>>>` [blue]`{"sum":1+2+3, "prod":1*2*3}` +
[green]`{"sum": 6, "prod": 6}`
.Dict operators
[cols="^2,^2,4,5"]
|===
| Symbol | Operation | Description | Examples
| [blue]`+` | _Join_ | Joins two dicts | [blue]`{1:"one"}+{6:"six"}` -> _{1: "one", 6: "six"}_
| [blue]`.` | _Dict item value_ | Item value of given key | [blue]`{"one":1, "two":2}."two"` -> _2_
| [blue]`in` | _Key in dict_ | True if key is in dict | [blue]`"one" in {"one":1, "two":2}` -> _true_ +
[blue]`"six" in {"one":1, "two":2}` -> _false_
|===
== Variables
_Expr_ supports variables like most programming languages. A variable is an identifier with an assigned value. Variables are stored in _contexts_.
_Expr_, like most programming languages, supports variables. A variable is an identifier with an assigned value. Variables are stored in _contexts_.
.Variable literal syntax
====
@ -467,12 +490,19 @@ The value of each sub-expression is stored in the automatica variable _last_.
=== [blue]`but` operator
[blue]`but` is an infixed operator. Its operands can be expressions of any type. It evaluates the left expression first, then the right expression. The value of the right expression is the final result. Examples: [blue]`5 but 2` returns 2, [blue]`x=2*3 but x-1` returns 5.
[blue]`but` is an infixed operator. Its operands can be expressions of any type. It evaluates the left expression first, then the right expression. The value of the right expression is the final result.
[blue]`but` is very similar to [blue]`;`. The only difference is that [blue]`;` can't be used inside parenthesis [blue]`(` and [blue]`)`.
.Examples
[blue]`5 but 2` +
[green]`2` +
[blue]`x=2*3 but x-1` +
[green]`5`.
[blue]`but` behavior is very similar to [blue]`;`. The only difference is that [blue]`;` is not a true operator and can't be used inside parenthesis [blue]`(` and [blue]`)`.
=== Assignment operator [blue]`=`
The assignment operator [blue]`=` is used to define variables in the evaluation context or to change their value (see _ExprContext_).
The assignment operator [blue]`=` is used to define variables or to change their value in the evaluation context (see _ExprContext_).
The value on the left side of [blue]`=` must be an identifier. The value on the right side can be any expression and it becomes the result of the assignment operation.
.Example
@ -540,11 +570,12 @@ NOTE: These operators have a high priority, in particular higher than the operat
The table below shows all supported operators by decreasing priorities.
.Operators priorities
[cols="^2,^2,^2,^5,^5"]
[cols="^2,^2,^2,^5,^6"]
|===
| Priority | Operators | Position | Operation | Operands and results
.1+|*ITEM*| [blue]`.` | _Infix_ | _Item_| _collection_ `"."` _key_ -> _any_
.2+|*ITEM*| [blue]`.` | _Infix_ | _List item_| _list_ `"."` _integer_ -> _any_
| [blue]`.` | _Infix_ | _Dict item_ | _dict_ `""` _any_ -> _any_
.2+|*INC*| [blue]`++` | _Postfix_ | _Post increment_| _integer-variable_ `"++"` -> _integer_
| [blue]`++` | _Postfix_ | _Next item_ | _iterator_ `"++"` -> _any_
.1+|*FACT*| [blue]`!` | _Postfix_ | _Factorial_| _integer_ `"!"` -> _integer_
@ -556,23 +587,28 @@ The table below shows all supported operators by decreasing priorities.
| [blue]`/` | _Infix_ | _Division_ | _number_ `"/"` _number_ -> _number_
| [blue]`./` | _Infix_ | _Float-division_ | __number__ `"./"` _number_ -> _float_
| [blue]`%` | _Infix_ | _Integer-remainder_ | _integer_ `"%"` _integer_ -> _integer_
.5+|*SUM*| [blue]`+` | _Infix_ | _Sum_ | _number_ `"+"` _number_ -> _number_
.6+|*SUM*| [blue]`+` | _Infix_ | _Sum_ | _number_ `"+"` _number_ -> _number_
| [blue]`+` | _Infix_ | _String-concat_ | (_string_\|_number_) `"+"` (_string_\|_number_) -> _string_
| [blue]`+` | _Infix_ | _List-join_ | _list_ `"+"` _list_ -> _list_
| [blue]`+` | _Infix_ | _Dict-join_ | _dict_ `"+"` _dict_ -> _dict_
| [blue]`-` | _Infix_ | _Subtraction_ | _number_ `"-"` _number_ -> _number_
| [blue]`-` | _Infix_ | _List-difference_ | _list_ `"-"` _list_ -> _list_
.6+|*RELATION*| [blue]`<` | _Infix_ | _less_ | _comparable_ `"<"` _comparable_ -> _boolean_
.8+|*RELATION*| [blue]`<` | _Infix_ | _less_ | _comparable_ `"<"` _comparable_ -> _boolean_
| [blue]`\<=` | _Infix_ | _less-equal_ | _comparable_ `"\<="` _comparable_ -> _boolean_
| [blue]`>` | _Infix_ | _greater_ | _comparable_ `">"` _comparable_ -> _boolean_
| [blue]`>=` | _Infix_ | _greater-equal_ | _comparable_ `">="` _comparable_ -> _boolean_
| [blue]`==` | _Infix_ | _equal_ | _comparable_ `"=="` _comparable_ -> _boolean_
| [blue]`!=` | _Infix_ | _not-equal_ | _comparable_ `"!="` _comparable_ -> _boolean_
| [blue]`in` | _Infix_ | _member-of-list_ | _any_ `"in"` _list_ -> _boolean_
| [blue]`in` | _Infix_ | _key-of-dict_ | _any_ `"in"` _dict_ -> _boolean_
.1+|*NOT*| [blue]`not` | _Prefix_ | _not_ | `"not"` _boolean_ -> _boolean_
.2+|*AND*| [blue]`and` | _Infix_ | _and_ | _boolean_ `"and"` _boolean_ -> _boolean_
| [blue]`&&` | _Infix_ | _and_ | _boolean_ `"&&"` _boolean_ -> _boolean_
.2+|*OR*| [blue]`or` | _Infix_ | _or_ | _boolean_ `"or"` _boolean_ -> _boolean_
| [blue]`\|\|` | _Infix_ | _or_ | _boolean_ `"\|\|"` _boolean_ -> _boolean_
.1+|*ASSIGN*| [blue]`=` | _Infix_ | _assignment_ | _identifier_ "=" _any_ -> _any_
.3+|*ASSIGN*| [blue]`=` | _Infix_ | _assignment_ | _identifier_ "=" _any_ -> _any_
| [blue]`>>` | _Infix_ | _front-insert_ | _any_ ">>" _list_ -> _list_
| [blue]`<<` | _Infix_ | _back-insert_ | _list_ "<<" _any_ -> _list_
.1+|*BUT*| [blue]`but` | _Infix_ | _but_ | _any_ "but" _any_ -> _any_
|===

View File

@ -999,14 +999,14 @@ pre.rouge .ss {
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">+</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>concatenation</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Join two strings or two <em>stringable</em> values</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">"one" + "two"</code> <em>["onetwo"]</em><br>
<code class="blue">"one" + 2</code> <em>["one2"]</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">"one" + "two"</code> &#8594; <em>"onetwo"</em><br>
<code class="blue">"one" + 2</code> &#8594; <em>"one2"</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">*</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>repeat</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Make <em>n</em> copy of a string</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">"one" * 2</code> <em>["oneone"]</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">"one" * 2</code> &#8594; <em>"oneone"</em></p></td>
</tr>
</tbody>
</table>
@ -1023,15 +1023,15 @@ pre.rouge .ss {
</div>
<div class="paragraph">
<div class="title">String examples</div>
<p><code>&gt;&gt;&gt;</code> <code class="blue">s="abc"</code> <em class="gray">assign the string to variable s</em><br>
<p><code>&gt;&gt;&gt;</code> <code class="blue">s="abc"</code> <em class="gray">// assign the string to variable s</em><br>
<code class="green">abc</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">s.1</code> <em class="gray">char at position 1 (starting from 0)</em><br>
<code>&gt;&gt;&gt;</code> <code class="blue">s.1</code> <em class="gray">// char at position 1 (starting from 0)</em><br>
<code class="green">b</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">s.(-1)</code> <em class="gray">char at position -1, the rightmost one</em><br>
<code>&gt;&gt;&gt;</code> <code class="blue">s.(-1)</code> <em class="gray">// char at position -1, the rightmost one</em><br>
<code class="green">c</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">#s</code> <em class="gray">number of chars</em><br>
<code>&gt;&gt;&gt;</code> <code class="blue">#s</code> <em class="gray">// number of chars</em><br>
<code class="gren">3</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">#"abc"</code> <em class="gray">number of chars</em><br>
<code>&gt;&gt;&gt;</code> <code class="blue">#"abc"</code> <em class="gray">// number of chars</em><br>
<code class="green">3</code></p>
</div>
</div>
@ -1227,6 +1227,31 @@ pre.rouge .ss {
<td class="tableblock halign-left valign-top"><p class="tableblock">Left list without elements in the right list</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">[1,2,3] - [2]</code> &#8594; <em>[1,3]</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">&gt;&gt;</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Front insertion</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Insert an item in front</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">0 &gt;&gt; [1,2]</code> &#8594; <em>[0,1,2]</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">&lt;&lt;</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Back insertion</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Insert an item at end</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">[1,2] &lt;&lt; 3</code> &#8594; <em>[1,2,3]</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">.</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>List item</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Item at given position</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">[1,2.3].1</code> &#8594; <em>2</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">in</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Item in list</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">True if item is in list</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">2 in [1,2,3]</code> &#8594; <em>true</em><br>
<code class="blue">6 in [1,2,3]</code> &#8594; <em>false</em></p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
@ -1236,7 +1261,7 @@ pre.rouge .ss {
<div class="title">Example 6. Item access syntax</div>
<div class="content">
<div class="paragraph">
<p><em>item</em> = <em>list-expr</em> "<strong>.</strong>" <em>list-expr</em></p>
<p><em>item</em> = <em>list-expr</em> "<strong>.</strong>" <em>integer-expr</em></p>
</div>
</div>
</div>
@ -1255,25 +1280,18 @@ pre.rouge .ss {
<code>&gt;&gt;&gt;</code> <code class="blue">list.(10)</code><br>
<code class="red">Eval Error: [1:9] index 10 out of bounds</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">#list</code><br>
<code class="green">3</code></p>
<code class="green">3</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">index=2; ["a", "b", "c", "d"].index</code><br>
<code class="green">c</code></p>
</div>
</div>
<div class="sect2">
<h3 id="_dictionaries"><a class="anchor" href="#_dictionaries"></a><a class="link" href="#_dictionaries">2.5. Dictionaries</a></h3>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Support for dictionaries is still ongoing.
</td>
</tr>
</table>
<div class="paragraph">
<p>The <em>dictionary</em>, or <em>dict</em>, data-type is set of pairs <em>key/value</em>. It is also known as <em>map</em> or <em>associative array</em>.</p>
</div>
<div class="paragraph">
<p>The <em>dictionary</em>, or <em>dict</em>, data-type is set of pairs <em>key/value</em>. It is also known as <em>map</em> or <em>associative array</em>. Dictionary literals are sequences of pairs separated by comma <code>,</code>; sequences are enclosed between brace brackets.</p>
<p>Dictionary literals are sequences of pairs separated by comma <code class="blue">,</code> enclosed between brace brackets.</p>
</div>
<div class="exampleblock">
<div class="title">Example 7. Dict literal syntax</div>
@ -1288,9 +1306,50 @@ Support for dictionaries is still ongoing.
<div class="paragraph">
<div class="title">Examples</div>
<p><code>&gt;&gt;&gt;</code> <code class="blue">{1:"one", 2:"two"}</code><br>
<code class="green">{1: "one", 2: "two"}</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">{"one":1, "two": 2}</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">{"sum":1+2+3, "prod":1*2*3}</code></p>
<code class="green">{"one": 1, "two": 2}</code><br>
<code>&gt;&gt;&gt;</code> <code class="blue">{"sum":1+2+3, "prod":1*2*3}</code><br>
<code class="green">{"sum": 6, "prod": 6}</code></p>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 7. Dict operators</caption>
<colgroup>
<col style="width: 15.3846%;">
<col style="width: 15.3846%;">
<col style="width: 30.7692%;">
<col style="width: 38.4616%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-center valign-top">Symbol</th>
<th class="tableblock halign-center valign-top">Operation</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Examples</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">+</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Join</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Joins two dicts</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">{1:"one"}+{6:"six"}</code> &#8594; <em>{1: "one", 6: "six"}</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">.</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Dict item value</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Item value of given key</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">{"one":1, "two":2}."two"</code> &#8594; <em>2</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">in</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Key in dict</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">True if key is in dict</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">"one" in {"one":1, "two":2}</code> &#8594; <em>true</em><br>
<code class="blue">"six" in {"one":1, "two":2}</code> &#8594; <em>false</em></p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@ -1298,7 +1357,7 @@ Support for dictionaries is still ongoing.
<h2 id="_variables"><a class="anchor" href="#_variables"></a><a class="link" href="#_variables">3. Variables</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p><em>Expr</em> supports variables like most programming languages. A variable is an identifier with an assigned value. Variables are stored in <em>contexts</em>.</p>
<p><em>Expr</em>, like most programming languages, supports variables. A variable is an identifier with an assigned value. Variables are stored in <em>contexts</em>.</p>
</div>
<div class="exampleblock">
<div class="title">Example 8. Variable literal syntax</div>
@ -1393,17 +1452,26 @@ Technically <code class="blue">;</code> is not treated as a real operator. It ac
<div class="sect2">
<h3 id="_but_operator"><a class="anchor" href="#_but_operator"></a><a class="link" href="#_but_operator">4.2. <code class="blue">but</code> operator</a></h3>
<div class="paragraph">
<p><code class="blue">but</code> is an infixed operator. Its operands can be expressions of any type. It evaluates the left expression first, then the right expression. The value of the right expression is the final result. Examples: <code class="blue">5 but 2</code> returns 2, <code class="blue">x=2*3 but x-1</code> returns 5.</p>
<p><code class="blue">but</code> is an infixed operator. Its operands can be expressions of any type. It evaluates the left expression first, then the right expression. The value of the right expression is the final result.</p>
</div>
<div class="paragraph">
<p><code class="blue">but</code> is very similar to <code class="blue">;</code>. The only difference is that <code class="blue">;</code> can&#8217;t be used inside parenthesis <code class="blue">(</code> and <code class="blue">)</code>.</p>
<div class="title">Examples</div>
<p><code class="blue">5 but 2</code><br>
<code class="green">2</code><br>
<code class="blue">x=2*3 but x-1</code><br>
<code class="green">5</code>.</p>
</div>
<div class="paragraph">
<p><code class="blue">but</code> behavior is very similar to <code class="blue">;</code>. The only difference is that <code class="blue">;</code> is not a true operator and can&#8217;t be used inside parenthesis <code class="blue">(</code> and <code class="blue">)</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_assignment_operator"><a class="anchor" href="#_assignment_operator"></a><a class="link" href="#_assignment_operator">4.3. Assignment operator <code class="blue">=</code></a></h3>
<div class="paragraph">
<p>The assignment operator <code class="blue">=</code> is used to define variables in the evaluation context or to change their value (see <em>ExprContext</em>).
The value on the left side of <code class="blue">=</code> must be an identifier. The value on the right side can be any expression and it becomes the result of the assignment operation.</p>
<p>The assignment operator <code class="blue">=</code> is used to define variables or to change their value in the evaluation context (see <em>ExprContext</em>).</p>
</div>
<div class="paragraph">
<p>The value on the left side of <code class="blue">=</code> must be an identifier. The value on the right side can be any expression and it becomes the result of the assignment operation.</p>
</div>
<div class="paragraph">
<div class="title">Example</div>
@ -1509,13 +1577,13 @@ These operators have a high priority, in particular higher than the operator <co
<p>The table below shows all supported operators by decreasing priorities.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<caption class="title">Table 7. Operators priorities</caption>
<caption class="title">Table 8. Operators priorities</caption>
<colgroup>
<col style="width: 12.5%;">
<col style="width: 12.5%;">
<col style="width: 12.5%;">
<col style="width: 31.25%;">
<col style="width: 31.25%;">
<col style="width: 11.7647%;">
<col style="width: 11.7647%;">
<col style="width: 11.7647%;">
<col style="width: 29.4117%;">
<col style="width: 35.2942%;">
</colgroup>
<thead>
<tr>
@ -1528,11 +1596,17 @@ These operators have a high priority, in particular higher than the operator <co
</thead>
<tbody>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><strong>ITEM</strong></p></td>
<td class="tableblock halign-center valign-top" rowspan="2"><p class="tableblock"><strong>ITEM</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">.</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Item</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>collection</em> <code>"."</code> <em>key</em> &#8594; <em>any</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>List item</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>list</em> <code>"."</code> <em>integer</em> &#8594; <em>any</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">.</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Dict item</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>dict</em> <code>""</code> <em>any</em> &#8594; <em>any</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" rowspan="2"><p class="tableblock"><strong>INC</strong></p></td>
@ -1605,7 +1679,7 @@ These operators have a high priority, in particular higher than the operator <co
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>integer</em> <code>"%"</code> <em>integer</em> &#8594; <em>integer</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" rowspan="5"><p class="tableblock"><strong>SUM</strong></p></td>
<td class="tableblock halign-center valign-top" rowspan="6"><p class="tableblock"><strong>SUM</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">+</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Sum</em></p></td>
@ -1624,6 +1698,12 @@ These operators have a high priority, in particular higher than the operator <co
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>list</em> <code>"+"</code> <em>list</em> &#8594; <em>list</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">+</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Dict-join</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>dict</em> <code>"+"</code> <em>dict</em> &#8594; <em>dict</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">-</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Subtraction</em></p></td>
@ -1636,7 +1716,7 @@ These operators have a high priority, in particular higher than the operator <co
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>list</em> <code>"-"</code> <em>list</em> &#8594; <em>list</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top" rowspan="6"><p class="tableblock"><strong>RELATION</strong></p></td>
<td class="tableblock halign-center valign-top" rowspan="8"><p class="tableblock"><strong>RELATION</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">&lt;</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>less</em></p></td>
@ -1673,6 +1753,18 @@ These operators have a high priority, in particular higher than the operator <co
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>comparable</em> <code>"!="</code> <em>comparable</em> &#8594; <em>boolean</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">in</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>member-of-list</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>any</em> <code>"in"</code> <em>list</em> &#8594; <em>boolean</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">in</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>key-of-dict</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>any</em> <code>"in"</code> <em>dict</em> &#8594; <em>boolean</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><strong>NOT</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">not</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Prefix</em></p></td>
@ -1706,13 +1798,25 @@ These operators have a high priority, in particular higher than the operator <co
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>boolean</em> <code>"||"</code> <em>boolean</em> &#8594; <em>boolean</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><strong>ASSIGN</strong></p></td>
<td class="tableblock halign-center valign-top" rowspan="3"><p class="tableblock"><strong>ASSIGN</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">=</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>assignment</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>identifier</em> "=" <em>any</em> &#8594; <em>any</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">&gt;&gt;</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>front-insert</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>any</em> "&gt;&gt;" <em>list</em> &#8594; <em>list</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">&lt;&lt;</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>back-insert</em></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>list</em> "&lt;&lt;" <em>any</em> &#8594; <em>list</em></p></td>
</tr>
<tr>
<td class="tableblock halign-center valign-top"><p class="tableblock"><strong>BUT</strong></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">but</code></p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Infix</em></p></td>
@ -1767,7 +1871,7 @@ These operators have a high priority, in particular higher than the operator <co
</div>
<div id="footer">
<div id="footer-text">
Last updated 2024-05-17 15:47:29 +0200
Last updated 2024-05-20 06:58:09 +0200
</div>
</div>
</body>