Doc: little changes
This commit is contained in:
parent
581f1585e6
commit
61d34fef7d
@ -310,7 +310,7 @@ The items of strings can be accessed using the square `[]` operator.
|
||||
_item_ = _string-expr_ "**[**" _integer-expr_ "**]**"
|
||||
====
|
||||
|
||||
.Sub string syntax
|
||||
.Sub-string syntax
|
||||
====
|
||||
_sub-string_ = _string-expr_ "**[**" _integer-expr_ "**:**" _integer-expr_ "**]**"
|
||||
====
|
||||
@ -371,14 +371,16 @@ Boolean data type has two values only: [blue]_true_ and [blue]_false_. Relationa
|
||||
|
||||
[CAUTION]
|
||||
====
|
||||
Currently, boolean operations are evaluated using _short cut evaluation_. This means that, if the left expression of the [blue]`and` and [blue]`or` operators is sufficient to establish the result of the whole operation, the right expression would not evaluated at all.
|
||||
|
||||
Currently, boolean operations are evaluated using _short cut evaluation_. This means that, if the left expression of the [blue]`and` and [blue]`or` operators is sufficient to establish the result of the whole operation, the right expression would not be evaluated at all.
|
||||
.Example
|
||||
[source,go]
|
||||
----
|
||||
2 > (a=1) or (a=8) > 0; a // <1>
|
||||
----
|
||||
<1> This multi-expression returns _1_ because in the first expression the left value of [blue]`or` is _true_ and as a conseguence its right value is not computed. Therefore the _a_ variable only receives the integer _1_.
|
||||
|
||||
|
||||
TIP: `dev-expr` provides the _ctrl()_ function that allows to change this behaviour.
|
||||
====
|
||||
|
||||
=== Lists
|
||||
@ -393,13 +395,13 @@ _non-empty-list_ = "**[**" _any-value_ {"**,**" _any-value} "**]**" +
|
||||
|
||||
.Examples
|
||||
`>>>` [blue]`[1,2,3]` [gray]_// List of integers_ +
|
||||
[green]`[1, 2, 3]` +
|
||||
[green]`[1, 2, 3]`
|
||||
`>>>` [blue]`["one", "two", "three"]` [gray]_// List of strings_ +
|
||||
[green]`["one", "two", "three"]` +
|
||||
[green]`["one", "two", "three"]`
|
||||
`>>>` [blue]`["one", 2, false, 4.1]` [gray]_// List of mixed-types_ +
|
||||
[green]`["one", 2, false, 4.1]` +
|
||||
[green]`["one", 2, false, 4.1]`
|
||||
`>>>` [blue]`["one"+1, 2.0*(9-2)]` [gray]_// List of expressions_ +
|
||||
[green]`["one1", 14]` +
|
||||
[green]`["one1", 14]`
|
||||
`>>>` [blue]`[ [1,"one"], [2,"two"]]` [gray]_// List of lists_ +
|
||||
[green]`[[1, "one"], [2, "two"]]`
|
||||
|
||||
@ -412,33 +414,38 @@ _non-empty-list_ = "**[**" _any-value_ {"**,**" _any-value} "**]**" +
|
||||
| [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]`[]` | _Item at index_ | 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.
|
||||
Array's items can be accessed using the index `[]` operator.
|
||||
|
||||
.Item access syntax
|
||||
====
|
||||
_item_ = _list-expr_ "**.**" _integer-expr_
|
||||
*_item_* = _list-expr_ "**[**" _integer-expr_ "**]**"
|
||||
====
|
||||
|
||||
.Sub-array (or slice of array) syntax
|
||||
====
|
||||
*_slice_* = _string-expr_ "**[**" _integer-expr_ "**:**" _integer-expr_ "**]**"
|
||||
====
|
||||
|
||||
.Items of list
|
||||
`>>>` [blue]`[1,2,3].1` +
|
||||
[green]`2` +
|
||||
[green]`2`
|
||||
`>>>` [blue]`list=[1,2,3]; list.1` +
|
||||
[green]`2` +
|
||||
[green]`2`
|
||||
`>>>` [blue]`["one","two","three"].1` +
|
||||
[green]`two` +
|
||||
[green]`two`
|
||||
`>>>` [blue]`list=["one","two","three"]; list.(2-1)` +
|
||||
[green]`two` +
|
||||
[green]`two`
|
||||
`>>>` [blue]`list.(-1)` +
|
||||
[green]`three` +
|
||||
[green]`three`
|
||||
`>>>` [blue]`list.(10)` +
|
||||
[red]`Eval Error: [1:9] index 10 out of bounds` +
|
||||
[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`
|
||||
|
||||
|
@ -1081,7 +1081,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</div>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 5. Sub string syntax</div>
|
||||
<div class="title">Example 5. Sub-string syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><em>sub-string</em> = <em>string-expr</em> "<strong>[</strong>" <em>integer-expr</em> "<strong>:</strong>" <em>integer-expr</em> "<strong>]</strong>"</p>
|
||||
@ -1221,10 +1221,10 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</td>
|
||||
<td class="content">
|
||||
<div class="paragraph">
|
||||
<p>Currently, boolean operations are evaluated using <em>short cut evaluation</em>. This means that, if the left expression of the <code class="blue">and</code> and <code class="blue">or</code> operators is sufficient to establish the result of the whole operation, the right expression would not evaluated at all.</p>
|
||||
<p>Currently, boolean operations are evaluated using <em>short cut evaluation</em>. This means that, if the left expression of the <code class="blue">and</code> and <code class="blue">or</code> operators is sufficient to establish the result of the whole operation, the right expression would not be evaluated at all.
|
||||
.Example</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="title">Example</div>
|
||||
<div class="content">
|
||||
<pre class="rouge highlight"><code data-lang="go"><span class="m">2</span> <span class="o">></span> <span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="m">1</span><span class="p">)</span> <span class="n">or</span> <span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="m">8</span><span class="p">)</span> <span class="o">></span> <span class="m">0</span><span class="p">;</span> <span class="n">a</span> <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
|
||||
</div>
|
||||
@ -1237,6 +1237,18 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="admonitionblock tip">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<i class="fa icon-tip" title="Tip"></i>
|
||||
</td>
|
||||
<td class="content">
|
||||
<code>dev-expr</code> provides the <em>ctrl()</em> function that allows to change this behaviour.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1260,13 +1272,13 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<div class="paragraph">
|
||||
<div class="title">Examples</div>
|
||||
<p><code>>>></code> <code class="blue">[1,2,3]</code> <em class="gray">// List of integers</em><br>
|
||||
<code class="green">[1, 2, 3]</code><br>
|
||||
<code class="green">[1, 2, 3]</code>
|
||||
<code>>>></code> <code class="blue">["one", "two", "three"]</code> <em class="gray">// List of strings</em><br>
|
||||
<code class="green">["one", "two", "three"]</code><br>
|
||||
<code class="green">["one", "two", "three"]</code>
|
||||
<code>>>></code> <code class="blue">["one", 2, false, 4.1]</code> <em class="gray">// List of mixed-types</em><br>
|
||||
<code class="green">["one", 2, false, 4.1]</code><br>
|
||||
<code class="green">["one", 2, false, 4.1]</code>
|
||||
<code>>>></code> <code class="blue">["one"+1, 2.0*(9-2)]</code> <em class="gray">// List of expressions</em><br>
|
||||
<code class="green">["one1", 14]</code><br>
|
||||
<code class="green">["one1", 14]</code>
|
||||
<code>>>></code> <code class="blue">[ [1,"one"], [2,"two"]]</code> <em class="gray">// List of lists</em><br>
|
||||
<code class="green">[[1, "one"], [2, "two"]]</code></p>
|
||||
</div>
|
||||
@ -1312,10 +1324,10 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">[1,2] << 3</code> → <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-center valign-top"><p class="tableblock"><code class="blue">[]</code></p></td>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><em>Item at index</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> → <em>2</em></p></td>
|
||||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code class="blue">[1,2,3][1]</code> → <em>2</em></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="tableblock halign-center valign-top"><p class="tableblock"><code class="blue">in</code></p></td>
|
||||
@ -1327,32 +1339,40 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="paragraph">
|
||||
<p>The items of array can be accessed using the dot <code>.</code> operator.</p>
|
||||
<p>Array’s items can be accessed using the index <code>[]</code> operator.</p>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 7. Item access syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><em>item</em> = <em>list-expr</em> "<strong>.</strong>" <em>integer-expr</em></p>
|
||||
<p><strong><em>item</em></strong> = <em>list-expr</em> "<strong>[</strong>" <em>integer-expr</em> "<strong>]</strong>"</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="exampleblock">
|
||||
<div class="title">Example 8. Sub-array (or slice of array) syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><strong><em>slice</em></strong> = <em>string-expr</em> "<strong>[</strong>" <em>integer-expr</em> "<strong>:</strong>" <em>integer-expr</em> "<strong>]</strong>"</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<div class="title">Items of list</div>
|
||||
<p><code>>>></code> <code class="blue">[1,2,3].1</code><br>
|
||||
<code class="green">2</code><br>
|
||||
<code class="green">2</code>
|
||||
<code>>>></code> <code class="blue">list=[1,2,3]; list.1</code><br>
|
||||
<code class="green">2</code><br>
|
||||
<code class="green">2</code>
|
||||
<code>>>></code> <code class="blue">["one","two","three"].1</code><br>
|
||||
<code class="green">two</code><br>
|
||||
<code class="green">two</code>
|
||||
<code>>>></code> <code class="blue">list=["one","two","three"]; list.(2-1)</code><br>
|
||||
<code class="green">two</code><br>
|
||||
<code class="green">two</code>
|
||||
<code>>>></code> <code class="blue">list.(-1)</code><br>
|
||||
<code class="green">three</code><br>
|
||||
<code class="green">three</code>
|
||||
<code>>>></code> <code class="blue">list.(10)</code><br>
|
||||
<code class="red">Eval Error: [1:9] index 10 out of bounds</code><br>
|
||||
<code class="red">Eval Error: [1:9] index 10 out of bounds</code>
|
||||
<code>>>></code> <code class="blue">#list</code><br>
|
||||
<code class="green">3</code><br>
|
||||
<code class="green">3</code>
|
||||
<code>>>></code> <code class="blue">index=2; ["a", "b", "c", "d"].index</code><br>
|
||||
<code class="green">c</code></p>
|
||||
</div>
|
||||
@ -1366,7 +1386,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<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 8. Dict literal syntax</div>
|
||||
<div class="title">Example 9. Dict literal syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><strong><em>dict</em></strong> = <em>empty-dict</em> | <em>non-empty-dict</em><br>
|
||||
@ -1432,7 +1452,7 @@ dev-expr <span class="nt">--</span> Expressions calculator v1.10.0<span class="o
|
||||
<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 9. Variable literal syntax</div>
|
||||
<div class="title">Example 10. Variable literal syntax</div>
|
||||
<div class="content">
|
||||
<div class="paragraph">
|
||||
<p><strong><em>variable</em></strong> = <em>identifier</em> "<strong>=</strong>" <em>any-value</em><br>
|
||||
@ -1953,7 +1973,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-06-19 22:03:01 +0200
|
||||
Last updated 2024-06-19 22:19:42 +0200
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user