3333 </tr >
3434</table >
3535
36- ## Supported Literals
36+ ## Literals
3737
38- The package supports:
38+ * ` true `
39+ * ` false `
40+ * ` nil `
3941
40- * ** strings** - single and double quotes (e.g. ` "hello" ` , ` 'hello' ` )
41- * ** numbers** - e.g. ` 103 ` , ` 2.5 ` , ` .5 `
42- * ** arrays** - e.g. ` [1, 2, 3] `
43- * ** maps** - e.g. ` {foo: "bar"} `
44- * ** booleans** - ` true ` and ` false `
45- * ** nil** - ` nil `
42+ ### Strings
4643
47- ## Digit separators
44+ Single or double quotes. Unicode sequences ( ` \uXXXX ` ) are supported.
4845
49- Integer literals may contain digit separators to allow digit grouping into more
50- legible forms.
46+ ### Numbers
5147
52- Example:
48+ Integers and floats.
5349
54- ``` js
55- 10_000_000_000
56- ```
50+ * ` 42 `
51+ * ` 3.14 `
52+ * ` 1e6 `
53+ * ` 0x2A `
54+ * ` 1_000_000 `
5755
58- ## Fields
56+ ### Arrays
5957
60- Struct fields and map elements can be accessed by using the ` . ` or the ` [] `
61- syntax.
58+ * ` [1, 2, 3] `
6259
63- ``` js
64- foo .Field
65- bar[" some-key" ]
66- ```
60+ Tailing commas are allowed.
6761
68- ## Functions
62+ ### Maps
6963
70- Functions may be called using the ` () ` syntax.
64+ * ` {foo: "bar"} `
7165
72- ``` js
73- foo .Method ()
74- ```
66+ Tailing commas are allowed.
7567
7668## Operators
7769
@@ -86,7 +78,7 @@ foo.Method()
8678
8779Example:
8880
89- ``` js
81+ ```
9082x^2 + y^2
9183```
9284
@@ -107,7 +99,7 @@ x^2 + y^2
10799
108100Example:
109101
110- ``` js
102+ ```
111103life < universe || life < everything
112104```
113105
@@ -121,23 +113,27 @@ life < universe || life < everything
121113
122114Example:
123115
124- ``` js
116+ ```
125117"hello" matches "h.*"
126118```
127119
128120### Membership Operators
129121
122+ * ` . ` (dot)
130123* ` in ` (contain)
131124* ` not in ` (does not contain)
132125
126+ Struct fields and map elements can be accessed by using the ` . ` or the ` [] `
127+ syntax.
128+
133129Example:
134130
135- ``` js
131+ ```
136132user.Group in ["human_resources", "marketing"]
137133```
138134
139- ``` js
140- " foo " in {foo: 1 , bar: 2 }
135+ ```
136+ data["tag-name"] in {foo: 1, bar: 2}
141137```
142138
143139### Range Operator
@@ -146,13 +142,13 @@ user.Group in ["human_resources", "marketing"]
146142
147143Example:
148144
149- ``` js
145+ ```
150146user.Age in 18..45
151147```
152148
153149The range is inclusive:
154150
155- ``` js
151+ ```
1561521..3 == [1, 2, 3]
157153```
158154
@@ -166,7 +162,7 @@ Example:
166162
167163Variable ` array ` is ` [1,2,3,4,5] ` .
168164
169- ``` js
165+ ```
170166array[1:4] == [2,3,4]
171167array[:3] == [1,2,3]
172168array[3:] == [4,5]
@@ -179,7 +175,7 @@ array[:] == array
179175
180176Example:
181177
182- ``` js
178+ ```
183179user.Age > 30 ? "mature" : "immature"
184180```
185181
@@ -190,7 +186,7 @@ user.Age > 30 ? "mature" : "immature"
190186Returns ** true** if all elements satisfies the [ predicate] ( #predicate ) .
191187If the array is empty, returns ** true** .
192188
193- ``` js
189+ ```
194190all(Tweets, {.Size < 280})
195191```
196192
@@ -199,13 +195,12 @@ all(Tweets, {.Size < 280})
199195Returns ** true** if any elements satisfies the [ predicate] ( #predicate ) .
200196If the array is empty, returns ** false** .
201197
202-
203198### ` one(array, predicate) `
204199
205200Returns ** true** if _ exactly one_ element satisfies the [ predicate] ( #predicate ) .
206201If the array is empty, returns ** false** .
207202
208- ``` js
203+ ```
209204one(Participants, {.Winner})
210205```
211206
@@ -232,22 +227,22 @@ Returns new array by filtering elements of the array by [predicate](#predicate).
232227Returns the number of elements what satisfies the [ predicate] ( #predicate ) .
233228Equivalent to:
234229
235- ``` js
230+ ```
236231len(filter(array, predicate))
237232```
238233
239234## Predicate
240235
241- The predicate is an expression that accepts a single argument. To access
236+ The predicate is an expression that accepts a single argument. To access
242237the argument use the ` # ` symbol.
243238
244- ``` js
239+ ```
245240map(0..9, {# / 2})
246241```
247242
248- If items of the array is a struct or a map, it is possible to access fields with
243+ If items of the array is a struct or a map, it is possible to access fields with
249244omitted ` # ` symbol (` #.Value ` becomes ` .Value ` ).
250245
251- ``` js
246+ ```
252247filter(Tweets, {len(.Value) > 280})
253248```
0 commit comments