README.adoc: example programs updated
This commit is contained in:
parent
a9b143d012
commit
bd323efedf
30
README.adoc
30
README.adoc
@ -68,7 +68,7 @@ import (
|
||||
|
||||
func main() {
|
||||
ctx := expr.NewSimpleVarStore()
|
||||
ctx.SetVar("var", int64(4))
|
||||
ctx.SetVar("var", 4)
|
||||
|
||||
source := `(3-1)*(10/5) == var`
|
||||
|
||||
@ -101,7 +101,7 @@ import (
|
||||
|
||||
func main() {
|
||||
ctx := expr.NewSimpleVarStore()
|
||||
ctx.SetVar("var", int64(4))
|
||||
ctx.SetVar("var", 4)
|
||||
|
||||
source := `(3-1)*(10/5) == var`
|
||||
|
||||
@ -121,14 +121,13 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.portale-stac.it/go-pkg/expr"
|
||||
)
|
||||
|
||||
func main() {
|
||||
source := `(3-1)*(10/5) == var`
|
||||
|
||||
if result, err := expr.EvalStringA(source, expr.Arg{"var", int64(4)}); err == nil {
|
||||
if result, err := expr.EvalStringA(source, expr.Arg{"var", 4}); err == nil {
|
||||
fmt.Printf("%q -> %v [%T]\n", source, result, result)
|
||||
} else {
|
||||
fmt.Println("Error calculating the expression:", err)
|
||||
@ -237,7 +236,28 @@ Currently, boolean operations are evaluated using _short cut evaluation_. This m
|
||||
====
|
||||
|
||||
==== List
|
||||
#TODO: List operations#
|
||||
_Expr_ supports list of mixed-type values, also specified by normal expressions.
|
||||
|
||||
.List examples
|
||||
[source,go]
|
||||
----
|
||||
[1, 2, 3] // List of integers
|
||||
["one", "two", "three"] // List of strings
|
||||
["one", 2, false, 4.1] // List of mixed-types
|
||||
["one"+1, 2.0*(9-2)] // List of expressions
|
||||
[ [1,"one"], [2,"two"]] // List of lists
|
||||
----
|
||||
|
||||
|
||||
.List operators
|
||||
[cols="^2,^2,5,4"]
|
||||
|===
|
||||
| Symbol | Operation | Description | Examples
|
||||
|
||||
| [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] ]_
|
||||
|===
|
||||
|
||||
=== Variables
|
||||
#TODO: variables#
|
||||
|
Loading…
Reference in New Issue
Block a user