diff --git a/doc/Expr.adoc b/doc/Expr.adoc index ff6a06b..25c9fae 100644 --- a/doc/Expr.adoc +++ b/doc/Expr.adoc @@ -141,7 +141,7 @@ Numbers can be integers (GO int64) or float (GO float64). In mixed operations in |=== === Fractions -_Expr_ also suports fractions. Fraction literals are made with tow integers separated by a vertical bar `|`. +_Expr_ also supports fractions. Fraction literals are made with two integers separated by a vertical bar `|`. .Examples // [source,go] @@ -149,7 +149,7 @@ _Expr_ also suports fractions. Fraction literals are made with tow integers sepa `>>>` [blue]`1 | 2` + [green]`1|2` + `>>>` [blue]`4|6` + -[green]`2|3` [gray]_Fractions are always reduced to theri lowest terms_ + +[green]`2|3` [gray]_Fractions are always reduced to their lowest terms_ + `>>>` [blue]`1|2 + 2|3` + [green]`7|6` + `>>>` [blue]`1|2 * 2|3` + @@ -245,7 +245,7 @@ Currently, boolean operations are evaluated using _short cut evaluation_. This m <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_. ==== -=== List +=== Lists _Expr_ supports list of mixed-type values, also specified by normal expressions. .List examples @@ -258,7 +258,6 @@ _Expr_ supports list of mixed-type values, also specified by normal expressions. [ [1,"one"], [2,"two"]] // List of lists ---- - .List operators [cols="^2,^2,5,4"] |=== @@ -269,6 +268,34 @@ _Expr_ supports list of mixed-type values, also specified by normal expressions. | [blue]`-` | _Difference_ | Left list without elements in the right list | [blue]`[1,2,3] - [2]` _[ [1,3] ]_ |=== +The items of array can be accessed using the dot `.` operator. + +.Item access syntax +[source,bnf] +---- + ::= "." +---- + +.Items of list +[source,go] +---- +`>>>` [blue]`[1,2,3].1` +[green]`2` +`>>>` [blue]`list=[1,2,3]; list.1` +[green]`2` +`>>>` [blue]`["one","two","three"].1` +[green]`two` +`>>>` [blue]`list=["one","two","three"]; list.(2-1)` +[green]`two` +`>>>` [blue]`list.(-1)` +[green]`three` +`>>>` [blue]`list.(-1)` +[green]`three` +`>>>` [blue]`list.(10)` +---- + + + == Dictionaries The _dictionary_ 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.