Doc: little changes

This commit is contained in:
2024-06-19 22:20:28 +02:00
parent 581f1585e6
commit 61d34fef7d
2 changed files with 66 additions and 39 deletions
+24 -17
View File
@@ -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`