Skip to content

Commit 3fe3504

Browse files
authored
Update Language-Definition.md
1 parent 3e9893b commit 3fe3504

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

docs/Language-Definition.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ d>
110110

111111
Examples:
112112

113-
```
113+
```python
114114
user.Age in 18..45 and user.Name not in ["admin", "root"]
115115
```
116116

117-
```
117+
```python
118118
foo matches "^[A-Z].*"
119119
```
120120

@@ -127,7 +127,7 @@ the last element.
127127

128128
The `in` operator can be used to check if an item is in an array or a map.
129129

130-
```
130+
```python
131131
user.Name in list["available-names"]
132132
```
133133

@@ -137,18 +137,17 @@ The `?.` operator can be used to access a field of a struct or an item of a map
137137
without checking if the struct or the map is `nil`. If the struct or the map is
138138
`nil`, the result of the expression is `nil`.
139139

140-
```
140+
```python
141141
author?.User?.Name
142142
```
143143

144-
145144
### Slice Operator
146145

147146
The slice operator `[:]` can be used to access a slice of an array.
148147

149148
For example, variable `array` is `[1, 2, 3, 4, 5]`:
150149

151-
```
150+
```python
152151
array[1:4] == [2, 3, 4]
153152
array[1:-1] == [2, 3, 4]
154153
array[:3] == [1, 2, 3]
@@ -164,7 +163,7 @@ array[:] == array
164163
<td>
165164
<a href="#allarray-predicate">all()</a><br>
166165
<a href="#anyarray-predicate">any()</a><br>
167-
<a href="#lenarray-predicate">one()</a><br>
166+
<a href="#onearray-predicate">one()</a><br>
168167
<a href="#nonearray-predicate">none()</a><br>
169168
</td>
170169
<td>
@@ -186,7 +185,7 @@ array[:] == array
186185
Returns **true** if all elements satisfies the [predicate](#predicate).
187186
If the array is empty, returns **true**.
188187

189-
```
188+
```python
190189
all(Tweets, {.Size < 280})
191190
```
192191

@@ -200,7 +199,7 @@ If the array is empty, returns **false**.
200199
Returns **true** if _exactly one_ element satisfies the [predicate](#predicate).
201200
If the array is empty, returns **false**.
202201

203-
```
202+
```python
204203
one(Participants, {.Winner})
205204
```
206205

@@ -223,7 +222,7 @@ Returns new array by filtering elements of the array by [predicate](#predicate).
223222
Returns the number of elements what satisfies the [predicate](#predicate).
224223
Equivalent to:
225224

226-
```
225+
```python
227226
len(filter(array, predicate))
228227
```
229228

@@ -239,7 +238,7 @@ Returns the absolute value of a number.
239238

240239
Returns the integer value of a number or a string.
241240

242-
```
241+
```python
243242
int("123") == 123
244243
```
245244

@@ -252,19 +251,19 @@ Returns the float value of a number or a string.
252251
The predicate is an expression that accepts a single argument. To access
253252
the argument use the `#` symbol.
254253

255-
```
254+
```python
256255
map(0..9, {# / 2})
257256
```
258257

259258
If items of the array is a struct or a map, it is possible to access fields with
260259
omitted `#` symbol (`#.Value` becomes `.Value`).
261260

262-
```
261+
```python
263262
filter(Tweets, {len(.Value) > 280})
264263
```
265264

266265
Braces `{}` can be omitted:
267266

268-
```
267+
```python
269268
filter(Tweets, len(.Value) > 280)
270269
```

0 commit comments

Comments
 (0)