110
110
111
111
Examples:
112
112
113
- ```
113
+ ``` python
114
114
user.Age in 18 ..45 and user.Name not in [" admin" , " root" ]
115
115
```
116
116
117
- ```
117
+ ``` python
118
118
foo matches " ^[A-Z].*"
119
119
```
120
120
@@ -127,7 +127,7 @@ the last element.
127
127
128
128
The ` in ` operator can be used to check if an item is in an array or a map.
129
129
130
- ```
130
+ ``` python
131
131
user.Name in list[" available-names" ]
132
132
```
133
133
@@ -137,18 +137,17 @@ The `?.` operator can be used to access a field of a struct or an item of a map
137
137
without checking if the struct or the map is ` nil ` . If the struct or the map is
138
138
` nil ` , the result of the expression is ` nil ` .
139
139
140
- ```
140
+ ``` python
141
141
author? .User? .Name
142
142
```
143
143
144
-
145
144
### Slice Operator
146
145
147
146
The slice operator ` [:] ` can be used to access a slice of an array.
148
147
149
148
For example, variable ` array ` is ` [1, 2, 3, 4, 5] ` :
150
149
151
- ```
150
+ ``` python
152
151
array[1 :4 ] == [2 , 3 , 4 ]
153
152
array[1 :- 1 ] == [2 , 3 , 4 ]
154
153
array[:3 ] == [1 , 2 , 3 ]
@@ -164,7 +163,7 @@ array[:] == array
164
163
<td>
165
164
<a href="#allarray-predicate">all()</a><br>
166
165
<a href="#anyarray-predicate">any()</a><br>
167
- <a href="#lenarray -predicate">one()</a><br>
166
+ <a href="#onearray -predicate">one()</a><br>
168
167
<a href="#nonearray-predicate">none()</a><br>
169
168
</td>
170
169
<td>
@@ -186,7 +185,7 @@ array[:] == array
186
185
Returns ** true** if all elements satisfies the [ predicate] ( #predicate ) .
187
186
If the array is empty, returns ** true** .
188
187
189
- ```
188
+ ``` python
190
189
all (Tweets, {.Size < 280 })
191
190
```
192
191
@@ -200,7 +199,7 @@ If the array is empty, returns **false**.
200
199
Returns ** true** if _ exactly one_ element satisfies the [ predicate] ( #predicate ) .
201
200
If the array is empty, returns ** false** .
202
201
203
- ```
202
+ ``` python
204
203
one(Participants, {.Winner})
205
204
```
206
205
@@ -223,7 +222,7 @@ Returns new array by filtering elements of the array by [predicate](#predicate).
223
222
Returns the number of elements what satisfies the [ predicate] ( #predicate ) .
224
223
Equivalent to:
225
224
226
- ```
225
+ ``` python
227
226
len (filter (array, predicate))
228
227
```
229
228
@@ -239,7 +238,7 @@ Returns the absolute value of a number.
239
238
240
239
Returns the integer value of a number or a string.
241
240
242
- ```
241
+ ``` python
243
242
int (" 123" ) == 123
244
243
```
245
244
@@ -252,19 +251,19 @@ Returns the float value of a number or a string.
252
251
The predicate is an expression that accepts a single argument. To access
253
252
the argument use the ` # ` symbol.
254
253
255
- ```
254
+ ``` python
256
255
map (0 ..9 , {# / 2})
257
256
```
258
257
259
258
If items of the array is a struct or a map , it is possible to access fields with
260
259
omitted `# ` symbol (`#.Value` becomes `.Value`).
261
260
262
- ```
261
+ ```python
263
262
filter (Tweets, {len (.Value) > 280 })
264
263
```
265
264
266
265
Braces `{}` can be omitted:
267
266
268
- ```
267
+ ```python
269
268
filter (Tweets, len (.Value) > 280 )
270
269
```
0 commit comments