From 61d34fef7d2341276b363898c8cea07641874ad6 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Wed, 19 Jun 2024 22:20:28 +0200 Subject: [PATCH] Doc: little changes --- doc/Expr.adoc | 41 +++++++++++++++++++-------------- doc/Expr.html | 64 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/doc/Expr.adoc b/doc/Expr.adoc index 77161c0..9ba2fd9 100644 --- a/doc/Expr.adoc +++ b/doc/Expr.adoc @@ -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` diff --git a/doc/Expr.html b/doc/Expr.html index d2b087d..ada312e 100644 --- a/doc/Expr.html +++ b/doc/Expr.html @@ -1081,7 +1081,7 @@ dev-expr -- Expressions calculator v1.10.0 -
Example 5. Sub string syntax
+
Example 5. Sub-string syntax

sub-string = string-expr "[" integer-expr ":" integer-expr "]"

@@ -1221,10 +1221,10 @@ dev-expr -- Expressions calculator v1.10.0
-

Currently, boolean operations are evaluated using short cut evaluation. This means that, if the left expression of the and and 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 and and or operators is sufficient to establish the result of the whole operation, the right expression would not be evaluated at all. +.Example

-
Example
2 > (a=1) or (a=8) > 0; a (1)
@@ -1237,6 +1237,18 @@ dev-expr -- Expressions calculator v1.10.0 + + + + + +
+ + +dev-expr provides the ctrl() function that allows to change this behaviour. +
+
@@ -1260,13 +1272,13 @@ dev-expr -- Expressions calculator v1.10.0
Examples

>>> [1,2,3] // List of integers
-[1, 2, 3]
+[1, 2, 3] >>> ["one", "two", "three"] // List of strings
-["one", "two", "three"]
+["one", "two", "three"] >>> ["one", 2, false, 4.1] // List of mixed-types
-["one", 2, false, 4.1]
+["one", 2, false, 4.1] >>> ["one"+1, 2.0*(9-2)] // List of expressions
-["one1", 14]
+["one1", 14] >>> [ [1,"one"], [2,"two"]] // List of lists
[[1, "one"], [2, "two"]]

@@ -1312,10 +1324,10 @@ dev-expr -- Expressions calculator v1.10.0

[1,2] << 3[1,2,3]

-

.

-

List item

+

[]

+

Item at index

Item at given position

-

[1,2.3].12

+

[1,2,3][1]2

in

@@ -1327,32 +1339,40 @@ dev-expr -- Expressions calculator v1.10.0 -

The items of array can be accessed using the dot . operator.

+

Array’s items can be accessed using the index [] operator.

Example 7. Item access syntax
-

item = list-expr "." integer-expr

+

item = list-expr "[" integer-expr "]"

+
+
+
+
+
Example 8. Sub-array (or slice of array) syntax
+
+
+

slice = string-expr "[" integer-expr ":" integer-expr "]"

Items of list

>>> [1,2,3].1
-2
+2 >>> list=[1,2,3]; list.1
-2
+2 >>> ["one","two","three"].1
-two
+two >>> list=["one","two","three"]; list.(2-1)
-two
+two >>> list.(-1)
-three
+three >>> list.(10)
-Eval Error: [1:9] index 10 out of bounds
+Eval Error: [1:9] index 10 out of bounds >>> #list
-3
+3 >>> index=2; ["a", "b", "c", "d"].index
c

@@ -1366,7 +1386,7 @@ dev-expr -- Expressions calculator v1.10.0, enclosed between brace brackets.

-
Example 8. Dict literal syntax
+
Example 9. Dict literal syntax

dict = empty-dict | non-empty-dict
@@ -1432,7 +1452,7 @@ dev-expr -- Expressions calculator v1.10.0

Example 9. Variable literal syntax
+
Example 10. Variable literal syntax

variable = identifier "=" any-value
@@ -1953,7 +1973,7 @@ These operators have a high priority, in particular higher than the operator