4242 <tr>
4343 <td>Map</td>
4444 <td>
45- <code>{ a: 1, b: 2, c: 3} </code>
45+ <code>{ a: 1, b: 2, c: 3} </code>
4646 </td>
4747 </tr>
4848 <tr>
49- <td>Nil</t
50- d>
49+ <td>Nil</td>
5150 <td>
5251 <code>nil</code>
5352 </td>
116115
117116Examples:
118117
119- ``` c++
118+ ``` expr
120119user.Age in 18..45 and user.Name not in ["admin", "root"]
121120```
122121
123- ``` c++
122+ ``` expr
124123foo matches "^[A-Z].*"
125124```
126125
@@ -143,7 +142,7 @@ The `?.` operator can be used to access a field of a struct or an item of a map
143142without checking if the struct or the map is ` nil ` . If the struct or the map is
144143` nil ` , the result of the expression is ` nil ` .
145144
146- ``` c++
145+ ``` expr
147146author?.User?.Name
148147```
149148
@@ -152,7 +151,7 @@ author?.User?.Name
152151The ` ?? ` operator can be used to return the left-hand side if it is not ` nil ` ,
153152otherwise the right-hand side is returned.
154153
155- ``` c++
154+ ``` expr
156155author?.User?.Name ?? "Anonymous"
157156```
158157
@@ -162,7 +161,7 @@ The slice operator `[:]` can be used to access a slice of an array.
162161
163162For example, variable ` array ` is ` [1, 2, 3, 4, 5] ` :
164163
165- ``` c++
164+ ``` expr
166165array[1:4] == [2, 3, 4]
167166array[1:-1] == [2, 3, 4]
168167array[:3] == [1, 2, 3]
@@ -173,34 +172,12 @@ array[:] == array
173172
174173## Built-in Functions
175174
176- <table >
177- <tr>
178- <td>
179- <a href="#allarray-predicate">all()</a><br>
180- <a href="#anyarray-predicate">any()</a><br>
181- <a href="#onearray-predicate">one()</a><br>
182- <a href="#nonearray-predicate">none()</a><br>
183- </td>
184- <td>
185- <a href="#maparray-predicate">map()</a><br>
186- <a href="#filterarray-predicate">filter()</a><br>
187- <a href="#countarray-predicate">count()</a><br>
188- </td>
189- <td>
190- <a href="#lenv">len()</a><br>
191- <a href="#absv">abs()</a><br>
192- <a href="#intv">int()</a><br>
193- <a href="#floatv">float()</a><br>
194- </td>
195- </tr>
196- </table >
197-
198175### all(array, predicate)
199176
200177Returns ** true** if all elements satisfies the [ predicate] ( #predicate ) .
201178If the array is empty, returns ** true** .
202179
203- ``` c++
180+ ``` expr
204181all(Tweets, {.Size < 280})
205182```
206183
@@ -214,7 +191,7 @@ If the array is empty, returns **false**.
214191Returns ** true** if _ exactly one_ element satisfies the [ predicate] ( #predicate ) .
215192If the array is empty, returns ** false** .
216193
217- ```c++
194+ ``` expr
218195one(Participants, {.Winner})
219196```
220197
@@ -237,7 +214,7 @@ Returns new array by filtering elements of the array by [predicate](#predicate).
237214Returns the number of elements what satisfies the [ predicate] ( #predicate ) .
238215Equivalent to:
239216
240- ``` c++
217+ ``` expr
241218len(filter(array, predicate))
242219```
243220
@@ -253,7 +230,7 @@ Returns the absolute value of a number.
253230
254231Returns the integer value of a number or a string.
255232
256- ```c++
233+ ``` expr
257234int("123") == 123
258235```
259236
@@ -266,19 +243,19 @@ Returns the float value of a number or a string.
266243The predicate is an expression that accepts a single argument. To access
267244the argument use the ` # ` symbol.
268245
269- ``` c++
246+ ``` expr
270247map(0..9, {# / 2})
271248```
272249
273250If items of the array is a struct or a map, it is possible to access fields with
274251omitted ` # ` symbol (` #.Value ` becomes ` .Value ` ).
275252
276- ```c++
253+ ``` expr
277254filter(Tweets, {len(.Value) > 280})
278255```
279256
280257Braces ` { ` ` } ` can be omitted:
281258
282- ``` c++
259+ ``` expr
283260filter(Tweets, len(.Value) > 280)
284261```
0 commit comments