@@ -133,31 +133,71 @@ Example:
133
133
user.Age > 30 ? "mature" : "immature"
134
134
```
135
135
136
- ## Builtin functions
136
+ ## Built-in Functions
137
137
138
- * ` len ` (length of array, map or string)
139
- * ` all ` (will return ` true ` if all element satisfies the predicate)
140
- * ` none ` (will return ` true ` if all element does NOT satisfy the predicate)
141
- * ` any ` (will return ` true ` if any element satisfies the predicate)
142
- * ` one ` (will return ` true ` if exactly ONE element satisfies the predicate)
143
- * ` filter ` (filter array by the predicate)
144
- * ` map ` (map all items with the closure)
145
- * ` count ` (returns number of elements what satisfies the predicate)
138
+ <table >
139
+ <tr >
140
+ <td >
141
+ <a href="#all">all()</a><br>
142
+ <a href="#any">any()</a><br>
143
+ <a href="#len">one()</a><br>
144
+ <a href="#none">none()</a><br>
145
+ </td >
146
+ <td >
147
+ <a href="#len">len()</a><br>
148
+ <a href="#map">map()</a><br>
149
+ <a href="#filter">filter()</a><br>
150
+ <a href="#count">count()</a><br>
151
+ </td >
152
+ </tr >
153
+ </table >
146
154
147
- Examples:
148
155
149
- Ensure all tweets are less than 280 chars.
156
+ #### ` all(array, predicate) `
157
+
158
+ Returns ** true** if all elements satisfies the predicate (or if the array is empty).
150
159
151
160
```
152
161
all(Tweets, {.Size < 280})
153
162
```
154
163
155
- Ensure there is exactly one winner.
164
+ #### ` any(array, predicate) `
165
+
166
+ Returns ** true** if any elements satisfies the predicate. If the array is empty, returns ** false** .
167
+
168
+
169
+ #### ` one(array, predicate) `
170
+
171
+ Returns ** true** if _ exactly one_ element satisfies the predicate. If the array is empty, returns ** false** .
156
172
157
173
```
158
174
one(Participants, {.Winner})
159
175
```
160
176
177
+ #### ` none(array, predicate) `
178
+
179
+ Returns ** true** if _ all elements does not_ satisfy the predicate. If the array is empty, returns ** true** .
180
+
181
+ #### ` len(v) `
182
+
183
+ Returns the length of an array, a map or a string.
184
+
185
+ #### ` map(array, closure) `
186
+
187
+ Returns new array by applying the closure to each element of the array.
188
+
189
+ #### ` filter(array, predicate) `
190
+
191
+ Returns new array by filtering elements of the array by predicate.
192
+
193
+ #### ` count(array, predicate) `
194
+
195
+ Returns the number of elements what satisfies the predicate. Equivalent to:
196
+
197
+ ```
198
+ len(filter(array, predicate))
199
+ ```
200
+
161
201
## Closures
162
202
163
203
The closure is an expression that accepts a single argument. To access
0 commit comments