1use crate::docs::entry::{FnEntry, StdEntry};
2
3pub static ARRAY: StdEntry = StdEntry {
4 name: "array",
5 description: "functions for array manipulation",
6 functions: FUNCTIONS,
7 since: None,
8 unstable: false,
9};
10
11static FUNCTIONS: &[&FnEntry] = &[
12 &ARR_CONCAT,
13 &ARR_CONTAINS,
14 &ARR_COUNT,
15 &ARR_FILL,
16 &ARR_FIRST,
17 &ARR_FLATTEN,
18 &ARR_INDEX_OF,
19 &ARR_INSERT,
20 &ARR_IS_EMPTY,
21 &ARR_LAST,
22 &ARR_MAX,
23 &ARR_MIN,
24 &ARR_POP,
25 &ARR_PRODUCT,
26 &ARR_PUSH,
27 &ARR_RANGE,
28 &ARR_REMOVE,
29 &ARR_REVERSE,
30 &ARR_SLICE,
31 &ARR_SORT,
32 &ARR_SUM,
33 &ARR_UNIQUE,
34 &LEN,
35 &ARR_ALL,
36 &ARR_ANY,
37 &ARR_FILTER,
38 &ARR_FIND,
39 &ARR_FIND_INDEX,
40 &ARR_FLAT_MAP,
41 &ARR_FOR_EACH,
42 &ARR_MAP,
43 &ARR_REDUCE,
44 &ARR_SORT_BY,
45 &ARR_ZIP,
46];
47
48static ARR_CONCAT: FnEntry = FnEntry {
49 signature: "arr_concat(arr1, arr2)",
50 description: "concatenates two arrays of the same type into one",
51 example: "get std::array::arr_concat\n\narr_concat([1, 2], [3, 4]) // [1, 2, 3, 4]",
52 expected_output: None,
53 returns: "",
54 errors: None,
55 see_also: &[],
56 since: None,
57};
58
59static ARR_CONTAINS: FnEntry = FnEntry {
60 signature: "arr_contains(arr, value)",
61 description: "true if the array contains the given value",
62 example: "get std::array::arr_contains\n\narr_contains([1, 2, 3], 2) // true",
63 expected_output: None,
64 returns: "",
65 errors: None,
66 see_also: &[],
67 since: None,
68};
69
70static ARR_COUNT: FnEntry = FnEntry {
71 signature: "arr_count(arr)",
72 description: "returns the number of elements in the array",
73 example: "get std::array::arr_count\n\narr_count([1, 2, 3]) // 3",
74 expected_output: None,
75 returns: "",
76 errors: None,
77 see_also: &[],
78 since: None,
79};
80
81static ARR_FILL: FnEntry = FnEntry {
82 signature: "arr_fill(value, count)",
83 description: "creates an array filled with value repeated count times",
84 example: "get std::array::arr_fill\n\narr_fill(0, 3) // [0, 0, 0]",
85 expected_output: None,
86 returns: "",
87 errors: None,
88 see_also: &[],
89 since: None,
90};
91
92static ARR_FIRST: FnEntry = FnEntry {
93 signature: "arr_first(arr)",
94 description: "returns the first element of the array",
95 example: "get std::array::arr_first\n\narr_first([1, 2, 3]) // 1",
96 expected_output: None,
97 returns: "",
98 errors: None,
99 see_also: &[],
100 since: None,
101};
102
103static ARR_FLATTEN: FnEntry = FnEntry {
104 signature: "arr_flatten(arr)",
105 description: "flattens a nested array into a single array",
106 example: "get std::array::arr_flatten\n\narr_flatten([[1, 2], [3, 4]]) // [1, 2, 3, 4]",
107 expected_output: None,
108 returns: "",
109 errors: None,
110 see_also: &[],
111 since: None,
112};
113
114static ARR_INDEX_OF: FnEntry = FnEntry {
115 signature: "arr_index_of(arr, index)",
116 description: "returns the element at the given index",
117 example: "get std::array::arr_index_of\n\narr_index_of([10, 20, 30], 1) // 20",
118 expected_output: None,
119 returns: "",
120 errors: None,
121 see_also: &[],
122 since: None,
123};
124
125static ARR_INSERT: FnEntry = FnEntry {
126 signature: "arr_insert(arr, value, index)",
127 description: "inserts value at the given index, shifting elements right",
128 example: "get std::array::arr_insert\n\narr_insert([1, 3], 2, 1) // [1, 2, 3]",
129 expected_output: None,
130 returns: "",
131 errors: None,
132 see_also: &[],
133 since: None,
134};
135
136static ARR_IS_EMPTY: FnEntry = FnEntry {
137 signature: "arr_is_empty(arr)",
138 description: "true if the array has no elements",
139 example: "get std::array::arr_is_empty\n\narr_is_empty([]) // true",
140 expected_output: None,
141 returns: "",
142 errors: None,
143 see_also: &[],
144 since: None,
145};
146
147static ARR_LAST: FnEntry = FnEntry {
148 signature: "arr_last(arr)",
149 description: "returns the last element of the array",
150 example: "get std::array::arr_last\n\narr_last([1, 2, 3]) // 3",
151 expected_output: None,
152 returns: "",
153 errors: None,
154 see_also: &[],
155 since: None,
156};
157
158static ARR_MAX: FnEntry = FnEntry {
159 signature: "arr_max(arr)",
160 description: "returns the largest element in an int or float array",
161 example: "get std::array::arr_max\n\narr_max([3, 1, 4, 1, 5]) // 5",
162 expected_output: None,
163 returns: "",
164 errors: None,
165 see_also: &[],
166 since: None,
167};
168
169static ARR_MIN: FnEntry = FnEntry {
170 signature: "arr_min(arr)",
171 description: "returns the smallest element in an int or float array",
172 example: "get std::array::arr_min\n\narr_min([3, 1, 4, 1, 5]) // 1",
173 expected_output: None,
174 returns: "",
175 errors: None,
176 see_also: &[],
177 since: None,
178};
179
180static ARR_POP: FnEntry = FnEntry {
181 signature: "arr_pop(arr)",
182 description: "removes the last element and returns the updated array",
183 example: "get std::array::arr_pop\n\narr_pop([1, 2, 3]) // [1, 2]",
184 expected_output: None,
185 returns: "",
186 errors: None,
187 see_also: &[],
188 since: None,
189};
190
191static ARR_PRODUCT: FnEntry = FnEntry {
192 signature: "arr_product(arr)",
193 description: "returns the product of all elements in an int or float array",
194 example: "get std::array::arr_product\n\narr_product([1, 2, 3, 4]) // 24",
195 expected_output: None,
196 returns: "",
197 errors: None,
198 see_also: &[],
199 since: None,
200};
201
202static ARR_PUSH: FnEntry = FnEntry {
203 signature: "arr_push(arr, value)",
204 description: "appends value to the end of the array and returns the updated array",
205 example: "get std::array::arr_push\n\narr_push([1, 2], 3) // [1, 2, 3]",
206 expected_output: None,
207 returns: "",
208 errors: None,
209 see_also: &[],
210 since: None,
211};
212
213static ARR_RANGE: FnEntry = FnEntry {
214 signature: "arr_range(start, end, step)",
215 description: "creates an int array from start to end (exclusive) with the given step",
216 example: "get std::array::arr_range\n\narr_range(0, 6, 2) // [0, 2, 4]",
217 expected_output: None,
218 returns: "",
219 errors: None,
220 see_also: &[],
221 since: None,
222};
223
224static ARR_REMOVE: FnEntry = FnEntry {
225 signature: "arr_remove(arr, index)",
226 description: "removes the element at the given index and returns the updated array",
227 example: "get std::array::arr_remove\n\narr_remove([1, 2, 3], 1) // [1, 3]",
228 expected_output: None,
229 returns: "",
230 errors: None,
231 see_also: &[],
232 since: None,
233};
234
235static ARR_REVERSE: FnEntry = FnEntry {
236 signature: "arr_reverse(arr)",
237 description: "reverses the order of elements in the array",
238 example: "get std::array::arr_reverse\n\narr_reverse([1, 2, 3]) // [3, 2, 1]",
239 expected_output: None,
240 returns: "",
241 errors: None,
242 see_also: &[],
243 since: None,
244};
245
246static ARR_SLICE: FnEntry = FnEntry {
247 signature: "arr_slice(arr, start, end)",
248 description: "returns a sub-array from start to end (exclusive)",
249 example: "get std::array::arr_slice\n\narr_slice([1, 2, 3, 4], 1, 3) // [2, 3]",
250 expected_output: None,
251 returns: "",
252 errors: None,
253 see_also: &[],
254 since: None,
255};
256
257static ARR_SORT: FnEntry = FnEntry {
258 signature: "arr_sort(arr)",
259 description: "returns the array sorted in ascending order, only int or float arrays",
260 example: "get std::array::arr_sort\n\narr_sort([3, 1, 2]) // [1, 2, 3]",
261 expected_output: None,
262 returns: "",
263 errors: None,
264 see_also: &[],
265 since: None,
266};
267
268static ARR_SUM: FnEntry = FnEntry {
269 signature: "arr_sum(arr)",
270 description: "returns the sum of all elements in an int or float array",
271 example: "get std::array::arr_sum\n\narr_sum([1, 2, 3, 4]) // 10",
272 expected_output: None,
273 returns: "",
274 errors: None,
275 see_also: &[],
276 since: None,
277};
278
279static ARR_UNIQUE: FnEntry = FnEntry {
280 signature: "arr_unique(arr)",
281 description: "returns the array with duplicate values removed, preserving order",
282 example: "get std::array::arr_unique\n\narr_unique([1, 2, 2, 3, 1]) // [1, 2, 3]",
283 expected_output: None,
284 returns: "",
285 errors: None,
286 see_also: &[],
287 since: None,
288};
289
290static LEN: FnEntry = FnEntry {
291 signature: "len(x)",
292 description: "length of string or array",
293 example: "get std::array::len\n\nlen(\"hello\") // 5",
294 expected_output: None,
295 returns: "",
296 errors: None,
297 see_also: &[],
298 since: None,
299};
300
301static ARR_ALL: FnEntry = FnEntry {
302 signature: "arr_all(arr, fn)",
303 description: "true if every element satisfies the predicate",
304 example: "get std::array::arr_all\n\narr_all([2, 4, 6], fn(int x) -> bool { return mod(x, 2) == 0 }) // true",
305 expected_output: None,
306 returns: "",
307 errors: None,
308 see_also: &[],
309 since: None,
310};
311
312static ARR_ANY: FnEntry = FnEntry {
313 signature: "arr_any(arr, fn)",
314 description: "true if at least one element satisfies the predicate",
315 example: "get std::array::arr_any\n\narr_any([1, 2, 3], fn(int x) -> bool { return x > 2 }) // true",
316 expected_output: None,
317 returns: "",
318 errors: None,
319 see_also: &[],
320 since: None,
321};
322
323static ARR_FILTER: FnEntry = FnEntry {
324 signature: "arr_filter(arr, fn)",
325 description: "returns a new array containing only elements where the predicate returns true",
326 example: "get std::array::arr_filter\n\narr_filter([1, 2, 3, 4], fn(int x) -> bool { return x > 2 }) // [3, 4]",
327 expected_output: None,
328 returns: "",
329 errors: None,
330 see_also: &[],
331 since: None,
332};
333
334static ARR_FIND: FnEntry = FnEntry {
335 signature: "arr_find(arr, fn)",
336 description: "returns the first element where the predicate returns true, or null if none match",
337 example: "get std::array::arr_find\n\narr_find([1, 2, 3, 4], fn(int x) -> bool { return x > 2 }) // 3",
338 expected_output: None,
339 returns: "",
340 errors: None,
341 see_also: &[],
342 since: None,
343};
344
345static ARR_FIND_INDEX: FnEntry = FnEntry {
346 signature: "arr_find_index(arr, fn)",
347 description: "returns the index of the first element where the predicate returns true, or -1 if none match",
348 example: "get std::array::arr_find_index\n\narr_find_index([10, 20, 30], fn(int x) -> bool { return x == 20 }) // 1",
349 expected_output: None,
350 returns: "",
351 errors: None,
352 see_also: &[],
353 since: None,
354};
355
356static ARR_FLAT_MAP: FnEntry = FnEntry {
357 signature: "arr_flat_map(arr, fn)",
358 description: "maps each element to an array via the callback then flattens the results one level",
359 example: "get std::array::arr_flat_map\n\narr_flat_map([1, 2, 3], fn(int x) -> arr[int] { return [x, x * 10] }) // [1, 10, 2, 20, 3, 30]",
360 expected_output: None,
361 returns: "",
362 errors: None,
363 see_also: &[],
364 since: None,
365};
366
367static ARR_FOR_EACH: FnEntry = FnEntry {
368 signature: "arr_for_each(arr, fn)",
369 description: "calls the callback on every element for side effects, returns null",
370 example: "get std::array::arr_for_each\n\narr_for_each([1, 2, 3], fn(int x) { println(x) })",
371 expected_output: None,
372 returns: "",
373 errors: None,
374 see_also: &[],
375 since: None,
376};
377
378static ARR_MAP: FnEntry = FnEntry {
379 signature: "arr_map(arr, fn)",
380 description: "returns a new array with each element transformed by the callback",
381 example: "get std::array::arr_map\n\narr_map([1, 2, 3], fn(int x) -> int { return x * 2 }) // [2, 4, 6]",
382 expected_output: None,
383 returns: "",
384 errors: None,
385 see_also: &[],
386 since: None,
387};
388
389static ARR_REDUCE: FnEntry = FnEntry {
390 signature: "arr_reduce(arr, fn, initial)",
391 description: "folds the array into a single value using the callback and a starting accumulator",
392 example: "get std::array::arr_reduce\n\narr_reduce([1, 2, 3, 4], fn(int acc, int x) -> int { return acc + x }, 0) // 10",
393 expected_output: None,
394 returns: "",
395 errors: None,
396 see_also: &[],
397 since: None,
398};
399
400static ARR_SORT_BY: FnEntry = FnEntry {
401 signature: "arr_sort_by(arr, fn)",
402 description: "sorts the array using a comparator callback that returns -1, 0, or 1",
403 example: "get std::array::arr_sort_by\n\narr_sort_by([3, 1, 2], fn(int a, int b) -> int { return a - b }) // [1, 2, 3]",
404 expected_output: None,
405 returns: "",
406 errors: None,
407 see_also: &[],
408 since: None,
409};
410
411static ARR_ZIP: FnEntry = FnEntry {
412 signature: "arr_zip(arr1, arr2)",
413 description: "zips two arrays into an array of tuples; stops at the shorter array",
414 example: "get std::array::arr_zip\n\narr_zip([1, 2, 3], [\"a\", \"b\", \"c\"]) // [(1, \"a\"), (2, \"b\"), (3, \"c\")]",
415 expected_output: None,
416 returns: "",
417 errors: None,
418 see_also: &[],
419 since: None,
420};