diff --git a/doc/Expr.adoc b/doc/Expr.adoc
index 050f203..a9a9810 100644
--- a/doc/Expr.adoc
+++ b/doc/Expr.adoc
@@ -1036,13 +1036,13 @@ Builtins are collection of function dedicated to specific domains of application
There are currently several builtin modules. More builtin modules will be added in the future.
.Available builtin modules
-* *base*: Base expression tools like isNil(), int(), etc.
-* *fmt*: String and console formatting functions
-* *import*: Functions import() and include()
-* *iterator*: Iterator helper functions
-* *math.arith*: Functions add() and mul()
-* *os.file*: Operating system file functions
-* *string*: string utilities
+* <<_module_base,*base*>>: Base expression tools like isNil(), int(), etc.
+* <<_module_fmt,*fmt*>>: String and console formatting functions
+* <<_module_import,*import*>>: Functions <<_import,import()>> and <<_include,include()>>
+* <<_module_iterator,*iterator*>>: Iterator helper functions
+* <<_module_math_arith,*math.arith*>>: Functions <<_add,add()>> and <<_mul,mul()>>
+* <<_module_os_file,*os.file*>>: Operating system file functions
+* <<_module_string,*string*>>: string utilities
Builtins activation is done by using the [blue]`BUILTIN` operator. All modules except "base" must be explicitly enabled. The syntax is as follows.
@@ -1095,144 +1095,144 @@ Syntax: `isBool() -> bool` +
Returns _true_ if the value type of __ is boolean, false otherwise.
.Examples
->>> isBool(true) +
-true +
->>> isBool(3==2) +
-true
+`>>>` [blue]`isBool(true)` +
+[green]`true` +
+`>>>` [blue]`isBool(3==2)` +
+[green]`true`
===== isDict()
Syntax: `isDict() -> bool` +
Returns _true_ if the value type of __ is dictionary, false otherwise.
.Examples
->>> isDict({}) +
-true +
->>> isDict({1: "one", 2: "two"}) +
-true +
->>> isDict(1:"one") +
-Eval Error: denominator must be integer, got string (one)
+`>>>` [blue]`isDict({})` +
+[green]`true` +
+`>>>` [blue]`isDict({1: "one", 2: "two"})` +
+[green]`true` +
+`>>>` [blue]`isDict(1:"one")` +
+[red]`Eval Error: denominator must be integer, got string (one)`
===== isFloat()
Syntax: `isFloat() -> bool` +
Returns _true_ if the value type of __ is float, false otherwise.
.Examples
->>> isFloat(4.) +
-true +
->>> isFloat(4) +
-false +
->>> isFloat("2.1") +
-false
+`>>>` [blue]`isFloat(4.)` +
+[green]`true` +
+`>>>` [blue]`isFloat(4)` +
+[green]`false` +
+`>>>` [blue]`isFloat("2.1")` +
+[green]`false`
===== isFract()
Syntax: `isFract() -> bool` +
Returns _true_ if the value type of __ is fraction, false otherwise.
.Examples
->>> isFract(4.5) +
-false +
->>> isFract(4:5) +
-true +
->>> isFract(4) +
-**false** +
->>> isFract(1.(3)) +
-true
+`>>>` [blue]`isFract(4.5)` +
+[green]`false` +
+`>>>` [blue]`isFract(4:5)` +
+[green]`true` +
+`>>>` [blue]`isFract(4)` +
+[green]**`false`** +
+`>>>` [blue]`isFract(1.(3))` +
+[green]`true`
===== isList()
Syntax: `isList() -> bool` +
Returns _true_ if the value type of __ is list, false otherwise.
.Examples
->>> isList([]) +
-true +
->>> isList([1, "2"])
-true
->>> isList(1,2)
-Eval Error: isList(): too many params -- expected 1, got 2
+`>>>` [blue]`isList([])` +
+[green]`true` +
+`>>>` [blue]`isList([1, "2"])` +
+[green]`true` +
+`>>>` [blue]`isList(1,2)` +
+[red]`Eval Error: isList(): too many params -- expected 1, got 2`
===== isNil()
Syntax: `isNil() -> bool` +
Returns _true_ if the value type of __ is nil, false otherwise.
.Examples
->>> isNil(nil)
-true
->>> isNil(1)
-false
+`>>>` [blue]`isNil(nil)` +
+[green]`true` +
+`>>>` [blue]`isNil(1)` +
+[green]`false`
===== isRational()
Syntax: `isRational() -> bool` +
Returns _true_ if the value type of __ is fraction or int, false otherwise.
.Examples
->>> isRational(4.5) +
-false +
->>> isRational(4:5) +
-true +
->>> isRational(4) +
-**true** +
->>> isRational(1.(3)) +
-true
+`>>>` [blue]`isRational(4.5)` +
+[green]`false` +
+`>>>` [blue]`isRational(4:5)` +
+[green]`true` +
+`>>>` [blue]`isRational(4)` +
+[green]**`true`** +
+`>>>` [blue]`isRational(1.(3))` +
+[green]`true`
===== isString()
Syntax: `isString() -> bool` +
Returns a boolean value , false otherwise.
.Examples
->>> isString("ciao") +
-true +
->>> isString(2) +
-false +
->>> isString(2+"2") +
-true
+`>>>` [blue]`isString("ciao")` +
+[green]`true` +
+`>>>` [blue]`isString(2)` +
+[green]`false` +
+`>>>` [blue]`isString(2+"2")` +
+[green]`true`
===== bool()
Syntax: `bool() -> bool` +
Returns a _boolean_ value consisent to the value of the expression.
.Examples
->>> bool(1)
-true
->>> bool(0)
-false
->>> bool("")
-false
->>> bool([])
-false
->>> bool([1])
-true
->>> bool({})
-false
->>> bool({1: "one"})
-true
+`>>>` [blue]`bool(1)` +
+[green]`true` +
+`>>>` [blue]`bool(0)` +
+[green]`false` +
+`>>>` [blue]`bool("")` +
+[green]`false` +
+`>>>` [blue]`bool([])` +
+[green]`false` +
+`>>>` [blue]`bool([1])` +
+[green]`true` +
+`>>>` [blue]`bool({})` +
+[green]`false` +
+`>>>` [blue]`bool({1: "one"})` +
+[green]`true`
===== int()
Syntax: `int() -> int` +
Returns an _integer_ value consistent with the value of the expression.
.Examples
->>> int(2) +
-2 +
->>> int("2") +
-2 +
->>> int("0x1") +
-Eval Error: strconv.Atoi: parsing "0x1": invalid syntax +
->>> int(0b10) +
-2 +
->>> int(0o2) +
-2 +
->>> int(0x2) +
-2 +
->>> int(1.8) +
-1 +
->>> int(5:2) +
-2 +
->>> int([]) +
-Eval Error: int(): can't convert list to int+
->>> int(true) +
-1 +
->>> int(false) +
-0
+`>>>` [blue]`int(2)` +
+[green]`2` +
+`>>>` [blue]`int("2")` +
+[green]`2` +
+`>>>` [blue]`int("0x1")` +
+[red]`Eval Error: strconv.Atoi: parsing "0x1": invalid syntax` +
+`>>>` [blue]`int(0b10)` +
+[green]`2` +
+`>>>` [blue]`int(0o2)` +
+[green]`2` +
+`>>>` [blue]`int(0x2)` +
+[green]`2` +
+`>>>` [blue]`int(1.8)` +
+[green]`1` +
+`>>>` [blue]`int(5:2)` +
+[green]`2` +
+`>>>` [blue]`int([])` +
+[red]`Eval Error: int(): can't convert list to int` +
+`>>>` [blue]`int(true)` +
+[green]`1` +
+`>>>` [blue]`int(false)` +
+[green]`0`
===== dec()
@@ -1240,66 +1240,66 @@ Syntax: `dec() -> float` +
Returns a _float_ value consistent with the value of the expression.
.Examples
->>> dec(2) +
-2 +
->>> dec(2.1) +
-2.1 +
->>> dec(2.3(1)) +
-2.311111111111111 +
->>> dec("3.14") +
-3.14 +
->>> dec(3:4) +
-0.75 +
->>> dec(true) +
-1 +
->>> dec(false) +
-0
+`>>>` [blue]`dec(2)` +
+[green]`2` +
+`>>>` [blue]`dec(2.1)` +
+[green]`2.1` +
+`>>>` [blue]`dec(2.3(1))` +
+[green]`2.311111111111111` +
+`>>>` [blue]`dec("3.14")` +
+[green]`3.14` +
+`>>>` [blue]`dec(3:4)` +
+[green]`0.75` +
+`>>>` [blue]`dec(true)` +
+[green]`1` +
+`>>>` [blue]`dec(false)` +
+[green]`0`
===== string()
Syntax: `string() -> string` +
Returns a _string_ value consistent with the value of the expression.
.Examples
->>> string(2) +
-"2" +
->>> string(0.8) +
-"0.8" +
->>> string([1,2]) +
-"[1, 2]" +
->>> string({1: "one", 2: "two"}) +
-"{1: "one", 2: "two"}" +
->>> string(2:5) +
-"2:5" +
->>> string(3==2) +
-"false"
+`>>>` [blue]`string(2)` +
+[green]`"2"` +
+`>>>` [blue]`string(0.8)` +
+[green]`"0.8"` +
+`>>>` [blue]`string([1,2])` +
+[green]`"[1, 2]"` +
+`>>>` [blue]`string({1: "one", 2: "two"})` +
+[green]`"{1: "one", 2: "two"}"` +
+`>>>` [blue]`string(2:5)` +
+[green]`"2:5"` +
+`>>>` [blue]`string(3==2)` +
+[green]`"false"`
===== fract()
Syntax: `fract() -> fraction` +
Returns a _fraction_ value consistent with the value of the expression.
.Examples
->>> fract(2) +
-2:1 +
->>> fract(2.5) +
-5:2 +
->>> fract("2.5") +
-5:2 +
->>> fract(1.(3)) +
-4:3 +
->>> fract([2]) +
-Eval Error: fract(): can't convert list to float +
->>> fract(false) +
-0:1 +
->>> fract(true) +
-1:1
+`>>>` [blue]`fract(2)` +
+[green]`2:1` +
+`>>>` [blue]`fract(2.5)` +
+[green]`5:2` +
+`>>>` [blue]`fract("2.5")` +
+[green]`5:2` +
+`>>>` [blue]`fract(1.(3))` +
+[green]`4:3` +
+`>>>` [blue]`fract([2])` +
+[red]`Eval Error: fract(): can't convert list to float` +
+`>>>` [blue]`fract(false)` +
+[green]`0:1` +
+`>>>` [blue]`fract(true)` +
+[green]`1:1`
===== eval()
Syntax: `eval() -> any` +
Computes and returns the value of the [.underline]#string# expression.
.Examples
->>> eval( "2 + fract(1.(3))" ) +
-10:3
+`>>>` [blue]`eval( "2 + fract(1.(3))" )` +
+[green]`10:3`
===== var()
Syntax: +
@@ -1309,14 +1309,14 @@ Syntax: +
This function allows you to define variables whose names must include special characters. The first form of the function allows you to define a variable with a name specified by the first parameter and assign it the value of the second parameter. The second form only returns the value of the variable with the specified name.
.Examples
->>> var("$x", 3+9) +
-12 +
->>> var("$x") +
-12 +
->>> var("gain%", var("$x")) +
-12 +
->>> var("gain%", var("$x")+1) +
-13
+`>>>` [blue]`var("$x", 3+9)` +
+[green]`12` +
+`>>>` [blue]`var("$x")` +
+[green]`12` +
+`>>>` [blue]`var("gain%", var("$x"))` +
+[green]`12` +
+`>>>` [blue]`var("gain%", var("$x")+1)` +
+[green]`13`
==== Module "fmt"
@@ -1346,22 +1346,24 @@ Syntax: +
Returns the sum of the values of the parameters. The parameters can be of any numeric type for which the [blue]`+` operator is defined. The result type depends on the types of the parameters. If all parameters are of the same type, the result is of that type. If the parameters are of different types, the result is of the type that can represent all the parameter types without loss of information. For example, if the parameters are a mix of integers and floats, the result is a float. If the parameters are a mix of number types, the result has the type of the most general one.
.Examples
->>> add(1,2,3) +
-6
->>> add(1.1,2.1,3.1) +
-6.300000000000001 +
->>> add("1","2","3") +
-Eval Error: add(): param nr 1 (1 in 0) has wrong type string, number expected +
->>> add(1:3, 2:3, 3:3) +
-2:1 +
->>> add(1, "2") +
-Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected +
->>> add([1,2,3]) +
-6 +
->>> iterator=$([1,2,3]); add(iterator) +
-6 +
->>> add($([1,2,3])) +
-6
+`>>>` [blue]`builtin "math.arith"` +
+[green]`1` +
+`>>>` [blue]`add(1,2,3)` +
+[green]`6` +
+`>>>` [blue]`add(1.1,2.1,3.1)` +
+[green]`6.300000000000001` +
+`>>>` [blue]`add("1","2","3")` +
+[red]`Eval Error: add(): param nr 1 (1 in 0) has wrong type string, number expected` +
+`>>>` [blue]`add(1:3, 2:3, 3:3)` +
+[green]`2:1` +
+`>>>` [blue]`add(1, "2")` +
+[red]`Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected` +
+`>>>` [blue]`add([1,2,3])` +
+[green]`6` +
+`>>>` [blue]`iterator=$([1,2,3]); add(iterator)` +
+[green]`6` +
+`>>>` [blue]`add($([1,2,3]))` +
+[green]`6`
===== mul()
Syntax: +
@@ -1369,8 +1371,13 @@ Syntax: +
`{4sp}mul(]) -> any` +
`{4sp}mul() -> any`
-Same as add() but returns the product of the values of the parameters.
+Same as <<_add,add()>> but returns the product of the values of the parameters.
+.Examples
+`>>>` [blue]`builtin "math.arith"` +
+[green]`1` +
+`>>>` [blue]`mul(2,3,4)` +
+[green]`24`
==== Module "os.file"
@@ -1392,45 +1399,131 @@ Same as add() but returns the product of the values of the parameters.
==== Module "string"
===== strJoin()
+Syntax: +
+`{4sp}strJoin(, - ...) -> string`
+
+Returns a string obtained by concatenating the string items (sarting from the second argument), separated by the string value of the separator.
+
+.Examples
+`>>>` [blue]`strJoin(", ", "one", "two", "three")` +
+[green]`"one, two, three"` +
+`>>>` [blue]`strJoin(", ", ["one", "two", "three"])` +
+[green]`"one, two, three"`
===== strSub()
+Syntax: +
+`{4sp}strSub(, =0, =-1) -> string`
+
+Returns a substring of the specified string starting at the specified index and having the specified length. If the start index is negative, it is interpreted as an offset from the end of the string. If the count is negative, it means to take all characters until the end of the string.
+
+.Examples
+`>>>` [blue]`strSub("Hello, world!", 7, 5)` +
+[green]`"world"` +
+`>>>` [blue]`strSub("Hello, world!", -6, 5)` +
+[green]`"world"` +
+`>>>` [blue]`strSub("Hello, world!", 7)` +
+[green]`"world!"` +
+`>>>` [blue]`strSub("Hello, world!", -6)` +
+[green]`"world!"`
===== strSplit()
+Syntax: +
+`{4sp}strSplit(, ="", =-1) -> list`
+
+Returns a list of substrings obtained by splitting the specified string using the specified separator. If the separator is an empty string, the string is split into individual characters. If the count is negative, it means to split all occurrences of the separator.
+
+.Examples
+`>>>` [blue]`strSplit("one, two, three", ", ")` +
+[green]`["one", "two", "three"]` +
+`>>>` [blue]`strSplit("one, two, three", ", ", 2)` +
+[green]`["one", "two, three"]` +
+`>>>` [blue]`strSplit("one, two, three")` +
+[green]`["o", "n", "e", ",", " ", "t", "w", "o", ",", " ", "t", "h", "r", "e", "e"]`
===== strTrim()
+Syntax: +
+`{4sp}strTrim() -> string`
+
+Returns a string obtained by removing leading and trailing whitespace characters from the specified string.
+
+.Examples
+`>>>` [blue]`strTrim(" Hello, world! ")` +
+[green]`"Hello, world!"`
===== strStartsWith()
+Syntax: +
+`{4sp}strStartsWith(, ...) -> bool`
+
+Returns a boolean indicating whether the specified string starts with any of the given prefixes.
+
+.Examples
+`>>>` [blue]`strStartsWith("Hello, world!", "Hello")` +
+[green]`true` +
+`>>>` [blue]`strStartsWith("Hello, world!", "world")` +
+[green]`false` +
+`>>>` [blue]`strStartsWith("Hello, world!", "Hi", "He")` +
+[green]`true`
+
===== strEndsWith()
+Syntax: +
+`{4sp}strEndsWith(, ...) -> bool`
+
+Returns a boolean indicating whether the specified string ends with any of the given suffixes.
+
+.Examples
+`>>>` [blue]`strEndsWith("Hello, world!", "world!")` +
+[green]`true` +
+`>>>` [blue]`strEndsWith("Hello, world!", "Hello")` +
+[green]`false` +
+`>>>` [blue]`strEndsWith("Hello, world!", "Hi", "world!")` +
+[green]`true`
+
===== strUpper()
+Syntax: +
+`{4sp}strUpper() -> string`
+
+Returns a string obtained by converting all characters of the specified string to uppercase.
+
+.Examples
+`>>>` [blue]`strUpper("Hello, world!")` +
+[green]`"HELLO, WORLD!"`
===== strLower()
+Syntax: +
+`{4sp}strLower() -> string`
+
+Returns a string obtained by converting all characters of the specified string to lowercase.
+
+.Examples
+`>>>` [blue]`strLower("Hello, world!")` +
+[green]`"hello, world!"`
== Iterators
Iterators are objects that can be used to traverse collections, such as lists and dictionaries. They are created by providing a _data-source_ object, the collection, in a `$()` expression. Once an iterator is created, it can be used to access the elements of the collection one by one.
In general, data-sources are objects that can be iterated over. They are defined as dictionaries having the key `next` whose value is a function that returns the next element of the collection and updates the state of the iterator. The _next_ function must return a special value, [blue]_nil_, when there are no more elements to iterate over.
-Lists and, soon, dictionaries, are implicit data-sources. The syntax for creating an iterator is as follows.
+Lists and dictionaries are implicit data-sources. The syntax for creating an iterator is as follows.
.Iterator creation syntax
====
*_iterator_* = "**$(**" _data-source_ "**)**" +
_data-source_ = _explicit_ | _list-spec_ | _dict-spec_ | _custom-data-source_
-_explicit_ = _any-expr_ { "," _any-expr_ }
+_explicit_ = _any-expr_ { "**,**" _any-expr_ }
_list-spec_ = _list_ _range-options_ +
-_list_ = "**[**" _any-expr_ { "," _any-expr_ } "**]**" +
-_range-options_ = [ "," _start-index_ [ "," _end-index_ [ "," _step_ ]]] +
+_list_ = "**[**" _any-expr_ { "**,**" _any-expr_ } "**]**" +
+_range-options_ = [ "**,**" _start-index_ [ "**,**" _end-index_ [ "**,**" _step_ ]]] +
_start-index_, _end-index_, _step_ = _integer-expr_
_dict-spec_ = _dict_ _dict-options_ +
-_dict_ = "**{**" _key-value-pair_ { "," _key-value-pair_ } "**}**" +
-_key-value-pair_ = _scalar-value_ ":" _any-expr_ +
+_dict_ = "**{**" _key-value-pair_ { "**,**" _key-value-pair_ } "**}**" +
+_key-value-pair_ = _scalar-value_ "**:**" _any-expr_ +
_scalar-value_ = _string_ | _number_ | _boolean_ +
-_dict-options_ = [ "," _sort-order_ [ "," _iter-mode_ ] ] +
+_dict-options_ = [ "**,**" _sort-order_ [ "**,**" _iter-mode_ ] ] +
_sort-order_ = _asc-order_ | _desc-order_ | _no-sort_ | _default-order_ +
_asc-order_ = "**asc**" | "**a**" +
_desc-order_ = "**desc**" | "**d**" +
diff --git a/doc/Expr.html b/doc/Expr.html
index 8f40df3..4343b4b 100644
--- a/doc/Expr.html
+++ b/doc/Expr.html
@@ -2698,25 +2698,25 @@ The clone modifier
@ does not make a variable a refere
Available builtin modules
-
-
base: Base expression tools like isNil(), int(), etc.
+base: Base expression tools like isNil(), int(), etc.
-
-
fmt: String and console formatting functions
+fmt: String and console formatting functions
-
-
import: Functions import() and include()
+import: Functions import() and include()
-
-
iterator: Iterator helper functions
+iterator: Iterator helper functions
-
-
math.arith: Functions add() and mul()
+math.arith: Functions add() and mul()
-
-
os.file: Operating system file functions
+os.file: Operating system file functions
-
-
string: string utilities
+string: string utilities
@@ -2830,10 +2830,10 @@ Returns true if the value type of <expr> is boolean, fal
Examples
-
>>> isBool(true)
-true
->>> isBool(3==2)
-true
+
>>> isBool(true)
+true
+>>> isBool(3==2)
+true
@@ -2844,12 +2844,12 @@ Returns true if the value type of <expr> is dictionary,
Examples
-
>>> isDict({})
-true
->>> isDict({1: "one", 2: "two"})
-true
->>> isDict(1:"one")
-Eval Error: denominator must be integer, got string (one)
+
>>> isDict({})
+true
+>>> isDict({1: "one", 2: "two"})
+true
+>>> isDict(1:"one")
+Eval Error: denominator must be integer, got string (one)
@@ -2860,12 +2860,12 @@ Returns true if the value type of <expr> is float, false
Examples
-
>>> isFloat(4.)
-true
->>> isFloat(4)
-false
->>> isFloat("2.1")
-false
+
>>> isFloat(4.)
+true
+>>> isFloat(4)
+false
+>>> isFloat("2.1")
+false
@@ -2876,14 +2876,14 @@ Returns true if the value type of <expr> is fraction, fa
Examples
-
>>> isFract(4.5)
-false
->>> isFract(4:5)
-true
->>> isFract(4)
-false
->>> isFract(1.(3))
-true
+
>>> isFract(4.5)
+false
+>>> isFract(4:5)
+true
+>>> isFract(4)
+false
+>>> isFract(1.(3))
+true
@@ -2894,12 +2894,12 @@ Returns true if the value type of <expr> is list, false
Examples
-
>>> isList([])
-true
->>> isList([1, "2"])
-true
->>> isList(1,2)
-Eval Error: isList(): too many params — expected 1, got 2
+
>>> isList([])
+true
+>>> isList([1, "2"])
+true
+>>> isList(1,2)
+Eval Error: isList(): too many params — expected 1, got 2
@@ -2910,10 +2910,10 @@ Returns true if the value type of <expr> is nil, false o
Examples
-
>>> isNil(nil)
-true
->>> isNil(1)
-false
+
>>> isNil(nil)
+true
+>>> isNil(1)
+false
@@ -2924,14 +2924,14 @@ Returns true if the value type of <expr> is fraction or
Examples
-
>>> isRational(4.5)
-false
->>> isRational(4:5)
-true
->>> isRational(4)
-true
->>> isRational(1.(3))
-true
+
>>> isRational(4.5)
+false
+>>> isRational(4:5)
+true
+>>> isRational(4)
+true
+>>> isRational(1.(3))
+true
@@ -2942,12 +2942,12 @@ Returns a boolean value , false otherwise.
Examples
-
>>> isString("ciao")
-true
->>> isString(2)
-false
->>> isString(2+"2")
-true
+
>>> isString("ciao")
+true
+>>> isString(2)
+false
+>>> isString(2+"2")
+true
@@ -2958,20 +2958,20 @@ Returns a boolean value consisent to the value of the expression.
Examples
-
>>> bool(1)
-true
->>> bool(0)
-false
->>> bool("")
-false
->>> bool([])
-false
->>> bool([1])
-true
->>> bool({})
-false
->>> bool({1: "one"})
-true
+
>>> bool(1)
+true
+>>> bool(0)
+false
+>>> bool("")
+false
+>>> bool([])
+false
+>>> bool([1])
+true
+>>> bool({})
+false
+>>> bool({1: "one"})
+true
@@ -2982,28 +2982,28 @@ Returns an integer value consistent with the value of the expression.
Examples
-
>>> int(2)
-2
->>> int("2")
-2
->>> int("0x1")
-Eval Error: strconv.Atoi: parsing "0x1": invalid syntax
->>> int(0b10)
-2
->>> int(0o2)
-2
->>> int(0x2)
-2
->>> int(1.8)
-1
->>> int(5:2)
-2
->>> int([])
-Eval Error: int(): can’t convert list to int+
->>> int(true)
-1
->>> int(false)
-0
+
>>> int(2)
+2
+>>> int("2")
+2
+>>> int("0x1")
+Eval Error: strconv.Atoi: parsing "0x1": invalid syntax
+>>> int(0b10)
+2
+>>> int(0o2)
+2
+>>> int(0x2)
+2
+>>> int(1.8)
+1
+>>> int(5:2)
+2
+>>> int([])
+Eval Error: int(): can’t convert list to int
+>>> int(true)
+1
+>>> int(false)
+0
@@ -3014,20 +3014,20 @@ Returns a float value consistent with the value of the expression.
Examples
-
>>> dec(2)
-2
->>> dec(2.1)
-2.1
->>> dec(2.3(1))
-2.311111111111111
->>> dec("3.14")
-3.14
->>> dec(3:4)
-0.75
->>> dec(true)
-1
->>> dec(false)
-0
+
>>> dec(2)
+2
+>>> dec(2.1)
+2.1
+>>> dec(2.3(1))
+2.311111111111111
+>>> dec("3.14")
+3.14
+>>> dec(3:4)
+0.75
+>>> dec(true)
+1
+>>> dec(false)
+0
@@ -3038,18 +3038,18 @@ Returns a string value consistent with the value of the expression.
Examples
-
>>> string(2)
-"2"
->>> string(0.8)
-"0.8"
->>> string([1,2])
-"[1, 2]"
->>> string({1: "one", 2: "two"})
-"{1: "one", 2: "two"}"
->>> string(2:5)
-"2:5"
->>> string(3==2)
-"false"
+
>>> string(2)
+"2"
+>>> string(0.8)
+"0.8"
+>>> string([1,2])
+"[1, 2]"
+>>> string({1: "one", 2: "two"})
+"{1: "one", 2: "two"}"
+>>> string(2:5)
+"2:5"
+>>> string(3==2)
+"false"
@@ -3060,20 +3060,20 @@ Returns a fraction value consistent with the value of the expression.
Examples
-
>>> fract(2)
-2:1
->>> fract(2.5)
-5:2
->>> fract("2.5")
-5:2
->>> fract(1.(3))
-4:3
->>> fract([2])
-Eval Error: fract(): can’t convert list to float
->>> fract(false)
-0:1
->>> fract(true)
-1:1
+
>>> fract(2)
+2:1
+>>> fract(2.5)
+5:2
+>>> fract("2.5")
+5:2
+>>> fract(1.(3))
+4:3
+>>> fract([2])
+Eval Error: fract(): can’t convert list to float
+>>> fract(false)
+0:1
+>>> fract(true)
+1:1
@@ -3084,8 +3084,8 @@ Computes and returns the value of the string expr
Examples
-
>>> eval( "2 + fract(1.(3))" )
-10:3
+
>>> eval( "2 + fract(1.(3))" )
+10:3
@@ -3100,14 +3100,14 @@ Computes and returns the value of the string expr
Examples
-
>>> var("$x", 3+9)
-12
->>> var("$x")
-12
->>> var("gain%", var("$x"))
-12
->>> var("gain%", var("$x")+1)
-13
+
>>> var("$x", 3+9)
+12
+>>> var("$x")
+12
+>>> var("gain%", var("$x"))
+12
+>>> var("gain%", var("$x")+1)
+13
@@ -3160,22 +3160,24 @@ Computes and returns the value of the string expr
Examples
-
>>> add(1,2,3)
-6
->>> add(1.1,2.1,3.1)
-6.300000000000001
->>> add("1","2","3")
-Eval Error: add(): param nr 1 (1 in 0) has wrong type string, number expected
->>> add(1:3, 2:3, 3:3)
-2:1
->>> add(1, "2")
-Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
->>> add([1,2,3])
-6
->>> iterator=$([1,2,3]); add(iterator)
-6
->>> add($([1,2,3]))
-6
+
>>> builtin "math.arith"
+1
+>>> add(1,2,3)
+6
+>>> add(1.1,2.1,3.1)
+6.300000000000001
+>>> add("1","2","3")
+Eval Error: add(): param nr 1 (1 in 0) has wrong type string, number expected
+>>> add(1:3, 2:3, 3:3)
+2:1
+>>> add(1, "2")
+Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
+>>> add([1,2,3])
+6
+>>> iterator=$([1,2,3]); add(iterator)
+6
+>>> add($([1,2,3]))
+6
@@ -3187,7 +3189,14 @@ Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
mul(<iterator-over-num-values>) → any
-
Same as add() but returns the product of the values of the parameters.
+
Same as add() but returns the product of the values of the parameters.
+
+
+
Examples
+
>>> builtin "math.arith"
+1
+>>> mul(2,3,4)
+24
@@ -3226,35 +3235,143 @@ Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
7.1.7. Module "string"
-
+
+
Syntax:
+ strJoin(<separator>, <item> …) → string
+
+
+
Returns a string obtained by concatenating the string items (sarting from the second argument), separated by the string value of the separator.
+
+
+
Examples
+
>>> strJoin(", ", "one", "two", "three")
+"one, two, three"
+>>> strJoin(", ", ["one", "two", "three"])
+"one, two, three"
+
-
+
+
Syntax:
+ strSub(<string>, <start-index>=0, <count>=-1) → string
+
+
+
Returns a substring of the specified string starting at the specified index and having the specified length. If the start index is negative, it is interpreted as an offset from the end of the string. If the count is negative, it means to take all characters until the end of the string.
+
+
+
Examples
+
>>> strSub("Hello, world!", 7, 5)
+"world"
+>>> strSub("Hello, world!", -6, 5)
+"world"
+>>> strSub("Hello, world!", 7)
+"world!"
+>>> strSub("Hello, world!", -6)
+"world!"
+
-
+
+
Syntax:
+ strSplit(<string>, <separator>="", <count>=-1) → list
+
+
+
Returns a list of substrings obtained by splitting the specified string using the specified separator. If the separator is an empty string, the string is split into individual characters. If the count is negative, it means to split all occurrences of the separator.
+
+
+
Examples
+
>>> strSplit("one, two, three", ", ")
+["one", "two", "three"]
+>>> strSplit("one, two, three", ", ", 2)
+["one", "two, three"]
+>>> strSplit("one, two, three")
+["o", "n", "e", ",", " ", "t", "w", "o", ",", " ", "t", "h", "r", "e", "e"]
+
-
+
+
Syntax:
+ strTrim(<string>) → string
+
+
+
Returns a string obtained by removing leading and trailing whitespace characters from the specified string.
+
+
+
Examples
+
>>> strTrim(" Hello, world! ")
+"Hello, world!"
+
-
+
+
Syntax:
+ strStartsWith(<string>, <prefix> …) → bool
+
+
+
Returns a boolean indicating whether the specified string starts with any of the given prefixes.
+
+
+
Examples
+
>>> strStartsWith("Hello, world!", "Hello")
+true
+>>> strStartsWith("Hello, world!", "world")
+false
+>>> strStartsWith("Hello, world!", "Hi", "He")
+true
+
-
+
+
Syntax:
+ strEndsWith(<string>, <suffix> …) → bool
+
+
+
Returns a boolean indicating whether the specified string ends with any of the given suffixes.
+
+
+
Examples
+
>>> strEndsWith("Hello, world!", "world!")
+true
+>>> strEndsWith("Hello, world!", "Hello")
+false
+>>> strEndsWith("Hello, world!", "Hi", "world!")
+true
+
-
+
+
Syntax:
+ strUpper(<string>) → string
+
+
+
Returns a string obtained by converting all characters of the specified string to uppercase.
+
+
+
Examples
+
>>> strUpper("Hello, world!")
+"HELLO, WORLD!"
+
-
+
+
Syntax:
+ strLower(<string>) → string
+
+
+
Returns a string obtained by converting all characters of the specified string to lowercase.
+
+
+
Examples
+
>>> strLower("Hello, world!")
+"hello, world!"
+
@@ -3270,7 +3387,7 @@ Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
In general, data-sources are objects that can be iterated over. They are defined as dictionaries having the key next whose value is a function that returns the next element of the collection and updates the state of the iterator. The next function must return a special value, nil, when there are no more elements to iterate over.
-
Lists and, soon, dictionaries, are implicit data-sources. The syntax for creating an iterator is as follows.
+
Lists and dictionaries are implicit data-sources. The syntax for creating an iterator is as follows.
Example 17. Iterator creation syntax
@@ -3280,20 +3397,20 @@ Eval Error: add(): param nr 2 (2 in 0) has wrong type string, number expected
data-source =
explicit |
list-spec |
dict-spec |
custom-data-source
-
explicit = any-expr { "," any-expr }
+
explicit = any-expr { "," any-expr }
list-spec = list range-options
-list = "[" any-expr { "," any-expr } "]"
-range-options = [ "," start-index [ "," end-index [ "," step ]]]
+list = "[" any-expr { "," any-expr } "]"
+range-options = [ "," start-index [ "," end-index [ "," step ]]]
start-index, end-index, step = integer-expr
dict-spec = dict dict-options
-dict = "{" key-value-pair { "," key-value-pair } "}"
-key-value-pair = scalar-value ":" any-expr
+dict = "{" key-value-pair { "," key-value-pair } "}"
+key-value-pair = scalar-value ":" any-expr
scalar-value = string | number | boolean
-dict-options = [ "," sort-order [ "," iter-mode ] ]
+dict-options = [ "," sort-order [ "," iter-mode ] ]
sort-order = asc-order | desc-order | no-sort | default-order
asc-order = "asc" | "a"
desc-order = "desc" | "d"
@@ -3361,7 +3478,7 @@ Currently, default-iter is the same as keys-iter. In the futur
Eval Error: EOF
-
On a list-type iterator creation expression, it is possible to specify an index range and a step to iterate over a subset of the list.
+
When creating a list-type iterator expression, you can specify a range of indices and a step to iterate over a subset of the list.
Indexing starts at 0. If the start index is not specified, it defaults to 0. If the end index is not specified, it defaults to the index of the last element of the list. If the step is not specified, it defaults to 1.
@@ -3493,7 +3610,7 @@ Iterators built on custom data-sources can provide additional named operators, d