...
Note: in addition to these operators, there is a membership infix operator that works on arrays and maps.
Table of Contents |
---|
Info | ||
---|---|---|
| ||
Functions which expected a key and then a value in classic KRL now expect a value and then a key in the Node Pico Engine. This applies to the |
Hash Paths
Many of the following operators take an argument that is a hash path. A hash path is an array whose elements represent the key values (for a map) or array indices of a path from the root of a complex data structure to the element of interest. For example, consider the following data structure:
...
Code Block | ||||
---|---|---|---|---|
| ||||
a = {"a": 3, "b": 4, "c": 5}; c = a.filter(function(v,k,v){v < 5}) // c = {"a": 3, "b": 4} d = a.filter(function(v,k,v){k eq "a"}) // d = {"a": 3} |
...
The map()
operator returns a map that contains the results of applying the function given as the operator's argument to each key-value pair from the original map. The function given as an argument must take two arguments: the first will be the key value and the second the valuekey. The result will be a map with the same keys, each key mapped to the result of the function. The length of the resulting map will be equal to the length of the target map. For example:
Code Block | ||||
---|---|---|---|---|
| ||||
a = {"a": 3, "b": 4, "c": 5}; c = a.map(function(v,k,v) {v+2}) // c = {"a": 5, "b": 6, "c": 7} |
...