UNPKG

69.4 kBTypeScriptView Raw
1/**
2 * Entries is an array of index-value pairs, with unique indices.
3 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/Entries)
4 */
5type Entries<T> = [number, T][];
6/**
7 * IEntries is a list of index-value pairs, with unique indices.
8 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/IEntries)
9 */
10type IEntries<T> = Iterable<[number, T]>;
11/**
12 * Lists is a pair of index array and value array, with unique indices.
13 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/Lists)
14 */
15type Lists<T> = [number[], T[]];
16/**
17 * ILists is a pair of index iterable list and value iterable list, with unique indices.
18 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ILists)
19 */
20type ILists<T> = [Iterable<number>, Iterable<T>];
21/**
22 * Handle reading of a single value.
23 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ReadFunction)
24 * @returns value
25 */
26type ReadFunction<T> = () => T;
27/**
28 * Handle combining of two values.
29 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/CombineFunction)
30 * @param a a value
31 * @param b another value
32 * @returns combined value
33 */
34type CombineFunction<T> = (a: T, b: T) => T;
35/**
36 * Handle comparison of two values.
37 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/CompareFunction)
38 * @param a a value
39 * @param b another value
40 * @returns a<b: -ve, a=b: 0, a>b: +ve
41 */
42type CompareFunction<T> = (a: T, b: T) => number;
43/**
44 * Handle processing of values in an array.
45 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ProcessFunction)
46 * @param v value in array
47 * @param i index of value in array
48 * @param x array containing the value
49 */
50type ProcessFunction<T> = (v: T, i: number, x: T[]) => void;
51/**
52 * Handle selection of values in an array.
53 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/TestFunction)
54 * @param v value in array
55 * @param i index of value in array
56 * @param x array containing the value
57 * @returns selected?
58 */
59type TestFunction<T> = (v: T, i: number, x: T[]) => boolean;
60/**
61 * Handle transformation of a value to another.
62 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/MapFunction)
63 * @param v value in array
64 * @param i index of value in array
65 * @param x array containing the value
66 * @returns transformed value
67 */
68type MapFunction<T, U> = (v: T, i: number, x: T[]) => U;
69/**
70 * Handle reduction of multiple values into a single value.
71 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ReduceFunction)
72 * @param acc accumulator (temporary result)
73 * @param v value in array
74 * @param i index of value in array
75 * @param x array containing the value
76 * @returns reduced value
77 */
78type ReduceFunction<T, U> = (acc: U, v: T, i: number, x: T[]) => U;
79/**
80 * Handle ending of a combined array.
81 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/EndFunction)
82 * @param dones iแต—สฐ array done?
83 * @returns combined array done?
84 */
85type EndFunction = (dones: boolean[]) => boolean;
86/**
87 * Handle swapping of two values in an array.
88 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/SwapFunction)
89 * @param x an array (updated!)
90 * @param i an index
91 * @param j another index
92 * @returns x | x[i] โ‡” x[j]
93 */
94type SwapFunction<T> = (x: T[], i: number, j: number) => T[];
95/**
96 * Generate array from given number range.
97 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fromRange)
98 * @param v start number
99 * @param V end number, excluding
100 * @param dv step size [1]
101 * @returns [v, v+dv, v+2dv, ...]
102 */
103declare function fromRange(v: number, V: number, dv?: number): number[];
104/**
105 * Generate array from repeated function invocation.
106 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fromInvocation)
107 * @param fn function
108 * @param n number of values
109 * @returns [fn(), fn(), ...]
110 */
111declare function fromInvocation<T>(fn: Function, n: number): T[];
112
113/**
114 * Generate array from repeated function application.
115 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fromApplication)
116 * @param fm map function (v, i)
117 * @param v start value
118 * @param n number of values
119 * @returns [v, fm(v), fm(fm(v)), ...]
120 */
121declare function fromApplication<T>(fm: MapFunction<T, T>, v: T, n: number): T[];
122
123/**
124 * Convert an iterable to array.
125 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fromIterable)
126 * @param x an iterable
127 * @returns x as array
128 */
129declare function fromIterable<T>(x: Iterable<T>): T[];
130
131/**
132 * Convert an iterable to array!
133 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fromIterable$)
134 * @param x an iterable (updatable if array!)
135 * @returns x as array
136 */
137declare function fromIterable$<T>(x: Iterable<T>): T[];
138
139/**
140 * Shallow clone an array.
141 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/shallowClone)
142 * @param x an array
143 * @returns shallow clone of x
144 */
145declare function shallowClone<T>(x: T[]): T[];
146
147/**
148 * Deep clone an array.
149 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/deepClone)
150 * @param x an array
151 * @returns deep clone of x
152 */
153declare function deepClone<T>(x: T[]): T[];
154/**
155 * Check if value is an array.
156 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/is)
157 * @param v a value
158 * @returns v is an array?
159 */
160declare function is(v: any): v is any[];
161/**
162 * Obtain all indices.
163 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/keys)
164 * @param x an array
165 * @returns [0, 1, ..., |x|-1]
166 */
167declare function keys<T>(x: T[]): number[];
168/**
169 * List all indices.
170 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ikeys)
171 * @param x an array
172 * @returns 0, 1, ..., |x|-1
173 */
174declare function ikeys<T>(x: T[]): IterableIterator<number>;
175/**
176 * Get all values.
177 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/values)
178 * @param x an array
179 * @returns [vโ‚€, vโ‚, ...] | vแตข = x[i]
180 */
181declare function values<T>(x: T[]): T[];
182/**
183 * List all values.
184 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ivalues)
185 * @param x an array
186 * @returns vโ‚€, vโ‚, ... | vแตข = x[i]
187 */
188declare function ivalues<T>(x: T[]): IterableIterator<T>;
189/**
190 * Obtain all index-value pairs.
191 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/entries)
192 * @param x an array
193 * @returns [[0, vโ‚€], [1, vโ‚], ...] | vแตข = x[i]
194 */
195declare function entries<T>(x: T[]): Entries<T>;
196/**
197 * List all index-value pairs.
198 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ientries)
199 * @param x an array
200 * @returns [0, vโ‚€], [1, vโ‚], ... | vแตข = x[i]
201 */
202declare function ientries<T>(x: T[]): IEntries<T>;
203/**
204 * Get zero-based index for an element in array.
205 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/index)
206 * @param x an array
207 * @param i ยฑindex
208 * @returns i' | x[i'] = x[i]; i' โˆˆ [0, |x|]
209 */
210declare function index<T>(x: T[], i: number): number;
211/**
212 * Get zero-based index range for part of array.
213 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/indexRange)
214 * @param x an array
215 * @param i begin ยฑindex [0]
216 * @param I end ยฑindex (exclusive) [|x|]
217 * @returns [i', I'] | i' โ‰ค I'; i', I' โˆˆ [0, |x|]
218 */
219declare function indexRange<T>(x: T[], i?: number, I?: number): [number, number];
220/**
221 * Check if an array is empty.
222 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isEmpty)
223 * @param x an array
224 * @returns |x| = 0?
225 */
226declare function isEmpty<T>(x: T[]): boolean;
227/**
228 * Find the length of an array.
229 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/length)
230 * @param x an array
231 * @param i begin ยฑindex [0]
232 * @param I end ยฑindex (exclusive) [X]
233 * @returns |x[i..I]|
234 */
235declare function length<T>(x: T[], i?: number, I?: number): number;
236
237/**
238 * Resize an array to given length!
239 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/resize$)
240 * @param x an array
241 * @param n new length
242 * @param vd default value
243 * @returns resized x
244 */
245declare function resize$<T>(x: T[], n: number, vd: T): T[];
246/**
247 * Remove all elements from an array!
248 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/clear$)
249 * @param x an array (updated!)
250 * @returns cleared x
251 */
252declare function clear$<T>(x: T[]): T[];
253/**
254 * Get value at index.
255 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/get)
256 * @param x an array
257 * @param i index
258 * @returns x[i]
259 */
260declare function get<T>(x: T[], i: number): T;
261
262/**
263 * Get values at indices.
264 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/getAll)
265 * @param x an array
266 * @param is indices
267 * @returns [x[iโ‚€], x[iโ‚], ...] | [iโ‚€, iโ‚, ...] = is
268 */
269declare function getAll<T>(x: T[], is: number[]): T[];
270/**
271 * Get value at path in a nested array.
272 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/getPath)
273 * @param x a nested array
274 * @param p path
275 * @returns x[iโ‚€][iโ‚][...] | [iโ‚€, iโ‚, ...] = p
276 */
277declare function getPath(x: any[], p: number[]): any;
278/**
279 * Check if nested array has a path.
280 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasPath)
281 * @param x a nested array
282 * @param p path
283 * @returns x[iโ‚€][iโ‚][...] exists? | [iโ‚€, iโ‚, ...] = p
284 */
285declare function hasPath(x: any[], p: number[]): boolean;
286/**
287 * Set value at index.
288 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/set)
289 * @param x an array
290 * @param i index
291 * @param v value
292 * @returns x' | x' = x; x'[i] = v
293 */
294declare function set<T>(x: T[], i: number, v: T): T[];
295
296/**
297 * Set value at index!
298 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/set$)
299 * @param x an array (updated!)
300 * @param i index
301 * @param v value
302 * @returns x | x[i] = v
303 */
304declare function set$<T>(x: T[], i: number, v: T): T[];
305/**
306 * Set value at path in a nested array!
307 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/setPath$)
308 * @param x a nested array (updated!)
309 * @param p path
310 * @param v value
311 * @returns x | x[iโ‚€][iโ‚][...] = v; [iโ‚€, iโ‚, ...] = p
312 */
313declare function setPath$(x: any[], p: number[], v: any): any[];
314/**
315 * Exchange two values.
316 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/swap)
317 * @param x an array
318 * @param i an index
319 * @param j another index
320 * @returns x' | x' = x; x'[i] = x[j]; x'[j] = x[i]
321 */
322declare function swap<T>(x: T[], i: number, j: number): T[];
323/**
324 * Exchange two values!
325 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/swap$)
326 * @param x an array (updated!)
327 * @param i an index
328 * @param j another index
329 * @returns x | x[i] โ‡” x[j]
330 */
331declare function swap$<T>(x: T[], i: number, j: number): T[];
332/**
333 * Exchange two ranges of values.
334 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/swapRanges)
335 * @param x an array
336 * @param i begin index of first range
337 * @param I end index of first range (exclusive)
338 * @param j begin index of second range
339 * @param J end index of second range (exclusive)
340 * @returns x' | x' = x; x'[i..I] = x[j..J]; x'[j..J] = x[i..I]
341 */
342declare function swapRanges<T>(x: T[], i: number, I: number, j: number, J: number): T[];
343/**
344 * Exchange two ranges of values!
345 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/swapRanges$)
346 * @param x an array (updated!)
347 * @param i begin index of first range
348 * @param I end index of first range (exclusive)
349 * @param j begin index of second range
350 * @param J end index of second range (exclusive)
351 * @returns x | x[i..I] โ‡” x[j..J]
352 */
353declare function swapRanges$<T>(x: T[], i: number, I: number, j: number, J: number): T[];
354/**
355 * Remove value at index.
356 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/remove)
357 * @param x an array
358 * @param i index
359 * @returns x[0..i] โงบ x[i+1..]
360 */
361declare function remove<T>(x: T[], i: number): T[];
362/**
363 * Remove value at index!
364 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/remove$)
365 * @param x an array (updated!)
366 * @param i index
367 * @returns x \\: [i]
368 */
369declare function remove$<T>(x: T[], i: number): T[];
370/**
371 * Remove value at path in a nested array!
372 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/removePath$)
373 * @param x a nested array (updated!)
374 * @param p path
375 * @returns x \\: [iโ‚€][iโ‚][...] | [iโ‚€, iโ‚, ...] = p
376 */
377declare function removePath$(x: any[], p: number[]): any[];
378/**
379 * Examine if array is sorted.
380 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isSorted)
381 * @param x an array
382 * @param fc compare function (a, b)
383 * @param fm map function (v, i, x)
384 * @returns x is sorted?
385 */
386declare function isSorted<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
387/**
388 * Examine if array has an unsorted value.
389 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasUnsortedValue)
390 * @param x an array
391 * @param fc compare function (a, b)
392 * @param fm map function (v, i, x)
393 * @returns x is not sorted?
394 */
395declare function hasUnsortedValue<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
396/**
397 * Find first index of an unsorted value.
398 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchUnsortedValue)
399 * @param x an array
400 * @param fc compare function (a, b)
401 * @param fm map function (v, i, x)
402 * @returns index of first unsorted value, -1 if sorted
403 */
404declare function searchUnsortedValue<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
405/**
406 * Arrange values in order.
407 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/sort)
408 * @param x an array
409 * @param fc compare function (a, b)
410 * @param fm map function (v, i, x)
411 * @param fs swap function (x, i, j)
412 * @returns x' | x' = x; x'[i] โ‰ค x'[j] โˆ€ i โ‰ค j
413 */
414declare function sort<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
415
416/**
417 * Arrange values in order!
418 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/sort$)
419 * @param x an array (updated!)
420 * @param fc compare function (a, b)
421 * @param fm map function (v, i, x)
422 * @param fs swap function (x, i, j)
423 * @returns x | x[i] โ‰ค x[j] โˆ€ i โ‰ค j
424 */
425declare function sort$<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
426/**
427 * Arrange a range of values in order.
428 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rangedSort)
429 * @param x an array
430 * @param i begin index
431 * @param I end index (exclusive)
432 * @param fc compare function (a, b)
433 * @param fm map function (v, i, x)
434 * @param fs swap function (x, i, j)
435 * @returns x' | x' = x; x'[i] โ‰ค x'[j] โˆ€ i โ‰ค j
436 */
437declare function rangedSort<T, U = T>(x: T[], i: number, I: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
438/**
439 * Arrange a range of values in order!
440 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rangedSort$)
441 * @param x an array (updated!)
442 * @param i begin index
443 * @param I end index (exclusive)
444 * @param fc compare function (a, b)
445 * @param fm map function (v, i, x)
446 * @param fs swap function (x, i, j)
447 * @returns x | x[i] โ‰ค x[j] โˆ€ i โ‰ค j
448 */
449declare function rangedSort$<T, U = T>(x: T[], i: number, I: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
450/**
451 * Partially arrange values in order.
452 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/partialSort)
453 * @param x an array
454 * @param n minimum number of values to sort
455 * @param fc compare function (a, b)
456 * @param fm map function (v, i, x)
457 * @param fs swap function (x, i, j)
458 * @returns x' | x' = x; x'[i] โ‰ค x'[j] โˆ€ i โ‰ค j
459 */
460declare function partialSort<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
461/**
462 * Partially arrange values in order!
463 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/partialSort$)
464 * @param x an array (updated!)
465 * @param n minimum number of values to sort
466 * @param fc compare function (a, b)
467 * @param fm map function (v, i, x)
468 * @param fs swap function (x, i, j)
469 * @returns x | x[i] โ‰ค x[j] โˆ€ i โ‰ค j
470 */
471declare function partialSort$<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
472/**
473 * Partially arrange a range of values in order.
474 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rangedPartialSort)
475 * @param x an array
476 * @param i begin index
477 * @param I end index (exclusive)
478 * @param n minimum number of values to sort
479 * @param fc compare function (a, b)
480 * @param fm map function (v, i, x)
481 * @param fs swap function (x, i, j)
482 * @returns x' | x' = x; x'[i] โ‰ค x'[j] โˆ€ i โ‰ค j
483 */
484declare function rangedPartialSort<T, U = T>(x: T[], i: number, I: number, n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
485/**
486 * Partially arrange a range of values in order!
487 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rangedPartialSort$)
488 * @param x an array (updated!)
489 * @param i begin index
490 * @param I end index (exclusive)
491 * @param n minimum number of values to sort
492 * @param fc compare function (a, b)
493 * @param fm map function (v, i, x)
494 * @param fs swap function (x, i, j)
495 * @returns x | x[i] โ‰ค x[j] โˆ€ i โ‰ค j
496 */
497declare function rangedPartialSort$<T, U = T>(x: T[], i: number, I: number, n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null, fs?: SwapFunction<T> | null): T[];
498/**
499 * Find first smallest value.
500 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/minimum)
501 * @param x an array
502 * @param fc compare function (a, b)
503 * @param fm map function (v, i, x)
504 * @returns v | v โ‰ค vแตข; vแตข โˆˆ x
505 */
506declare function minimum<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T;
507
508/**
509 * Find first smallest entry.
510 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/minimumEntry)
511 * @param x an array
512 * @param fc compare function (a, b)
513 * @param fm map function (v, i, x)
514 * @returns [min_index, min_value]
515 */
516declare function minimumEntry<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [number, T];
517
518/**
519 * Find first largest value.
520 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/maximum)
521 * @param x an array
522 * @param fc compare function (a, b)
523 * @param fm map function (v, i, x)
524 * @returns v | v โ‰ฅ vแตข; vแตข โˆˆ x
525 */
526declare function maximum<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T;
527
528/**
529 * Find first largest entry.
530 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/maximumEntry)
531 * @param x an array
532 * @param fc compare function (a, b)
533 * @param fm map function (v, i, x)
534 * @returns [max_index, max_value]
535 */
536declare function maximumEntry<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [number, T];
537
538/**
539 * Find smallest and largest values.
540 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/range)
541 * @param x an array
542 * @param fc compare function (a, b)
543 * @param fm map function (v, i, x)
544 * @returns [min_value, max_value]
545 */
546declare function range<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [T, T];
547/**
548 * Find smallest and largest entries.
549 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rangeEntries)
550 * @param x an array
551 * @param fc compare function (a, b)
552 * @param fm map function (v, i, x)
553 * @returns [min_entry, max_entry]
554 */
555declare function rangeEntries<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [[number, T], [number, T]];
556/**
557 * Find smallest values.
558 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/minimums)
559 * @param x an array
560 * @param n number of values
561 * @param fc compare function (a, b)
562 * @param fm map function (v, i, x)
563 * @returns n smallest values in ascending order
564 */
565declare function minimums<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
566/**
567 * Find smallest entries.
568 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/minimumEntries)
569 * @param x an array
570 * @param n number of values
571 * @param fc compare function (a, b)
572 * @param fm map function (v, i, x)
573 * @returns n smallest entries in ascending order
574 */
575declare function minimumEntries<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [number, T][];
576/**
577 * Find largest values.
578 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/maximums)
579 * @param x an array
580 * @param n number of values
581 * @param fc compare function (a, b)
582 * @param fm map function (v, i, x)
583 * @returns n largest values in descending order
584 */
585declare function maximums<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
586/**
587 * Find largest entries.
588 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/maximumEntries)
589 * @param x an array
590 * @param n number of values
591 * @param fc compare function (a, b)
592 * @param fm map function (v, i, x)
593 * @returns n largest entries in descending order
594 */
595declare function maximumEntries<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): [number, T][];
596/**
597 * Find first index of minimum value.
598 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchMinimumValue)
599 * @param x an array
600 * @param fc compare function (a, b)
601 * @param fm map function (v, i, x)
602 * @returns first index of minimum value, -1 if empty
603 */
604declare function searchMinimumValue<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
605/**
606 * Find first index of maximum value.
607 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchMaximumValue)
608 * @param x an array
609 * @param fc compare function (a, b)
610 * @param fm map function (v, i, x)
611 * @returns first index of maximum value, -1 if empty
612 */
613declare function searchMaximumValue<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
614/**
615 * Find indices of minimum values.
616 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchMinimumValues)
617 * @param x an array
618 * @param n number of values
619 * @param fc compare function (a, b)
620 * @param fm map function (v, i, x)
621 * @returns indices of minimum values in ascending order
622 */
623declare function searchMinimumValues<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number[];
624/**
625 * Find indices of maximum values.
626 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchMaximumValues)
627 * @param x an array
628 * @param n number of values
629 * @param fc compare function (a, b)
630 * @param fm map function (v, i, x)
631 * @returns indices of maximum values in descending order
632 */
633declare function searchMaximumValues<T, U = T>(x: T[], n: number, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number[];
634/**
635 * Examine if two arrays are equal.
636 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isEqual)
637 * @param x an array
638 * @param y another array
639 * @param fc compare function (a, b)
640 * @param fm map function (v, i, x)
641 * @returns x = y?
642 */
643declare function isEqual<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
644/**
645 * Compare two arrays (lexicographically).
646 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/compare)
647 * @param x an array
648 * @param y another array
649 * @param fc compare function (a, b)
650 * @param fm map function (v, i, x)
651 * @returns x<y: -ve, x=y: 0, x>y: +ve
652 */
653declare function compare<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
654/**
655 * Get first value.
656 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/head)
657 * @param x an array
658 * @param vd default value
659 * @returns x[0] || vd
660 */
661declare function head<T>(x: T[], vd?: T): T;
662
663/**
664 * Get values except first.
665 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/tail)
666 * @param x an array
667 * @returns x[1..|x|]
668 */
669declare function tail<T>(x: T[]): T[];
670/**
671 * Get values except last.
672 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/init)
673 * @param x an array
674 * @returns x[0..|x|-1]
675 */
676declare function init<T>(x: T[]): T[];
677/**
678 * Get last value.
679 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/last)
680 * @param x an array
681 * @param vd default value
682 * @returns x[|x|-1] || vd
683 */
684declare function last<T>(x: T[], vd?: T): T;
685
686/**
687 * Get values from middle.
688 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/middle)
689 * @param x an array
690 * @param i begin index
691 * @param n number of values [1]
692 * @returns x[i..i+n]
693 */
694declare function middle<T>(x: T[], i: number, n?: number): T[];
695/**
696 * Get part of an array.
697 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/slice)
698 * @param x an array
699 * @param i begin index [0]
700 * @param I end index [|x|]
701 * @returns x[i..I]
702 */
703declare function slice<T>(x: T[], i?: number, I?: number): T[];
704/**
705 * Get part of an array!
706 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/slice$)
707 * @param x an array (updated!)
708 * @param i begin index [0]
709 * @param I end index [|x|]
710 * @returns x = x[i..I]
711 */
712declare function slice$<T>(x: T[], i?: number, I?: number): T[];
713/**
714 * Check if array has a value.
715 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/includes)
716 * @param x an array
717 * @param v search value
718 * @param i begin index [0]
719 * @returns v โˆˆ x[i..]?
720 */
721declare function includes<T>(x: T[], v: T, i?: number): boolean;
722/**
723 * Examine if array has a value.
724 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasValue)
725 * @param x an array
726 * @param v search value
727 * @param fc compare function (a, b)
728 * @param fm map function (v, i, x)
729 * @returns v โˆˆ x?
730 */
731declare function hasValue<T, U = T>(x: T[], v: T, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
732/**
733 * Find first index of a value.
734 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchValue)
735 * @param x an array
736 * @param v search value
737 * @param fc compare function (a, b)
738 * @param fm map function (v, i, x)
739 * @returns first index of value, -1 if not found
740 */
741declare function searchValue<T, U = T>(x: T[], v: T, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
742/**
743 * Find last index of a value.
744 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchValueRight)
745 * @param x an array
746 * @param v search value
747 * @param fc compare function (a, b)
748 * @param fm map function (v, i, x)
749 * @returns last index of value, -1 if not found
750 */
751declare function searchValueRight<T, U = T>(x: T[], v: T, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
752/**
753 * Find indices of value.
754 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchValueAll)
755 * @param x an array
756 * @param v search value
757 * @param fc compare function (a, b)
758 * @param fm map function (v, i, x)
759 * @returns indices of value
760 */
761declare function searchValueAll<T, U = T>(x: T[], v: T, fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number[];
762/**
763 * Find first index of an adjacent duplicate value.
764 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchAdjacentDuplicateValue)
765 * @param x an array
766 * @param fc compare function (a, b)
767 * @param fm map function (v, i, x)
768 * @returns index of first adjacent duplicate value, -1 if none
769 */
770declare function searchAdjacentDuplicateValue<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
771
772/**
773 * Find first index where two arrays differ.
774 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchMismatchedValue)
775 * @param x an array
776 * @param y another array
777 * @param fc compare function (a, b)
778 * @param fm map function (v, i, x)
779 * @returns first index where x[i] โ‰  y[i], or -1
780 */
781declare function searchMismatchedValue<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
782
783/**
784 * Examine if array starts with a prefix.
785 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasPrefix)
786 * @param x an array
787 * @param y search prefix
788 * @param fc compare function (a, b)
789 * @param fm map function (v, i, x)
790 * @returns x[0..|y|] = y?
791 */
792declare function hasPrefix<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
793
794/**
795 * Examine if array ends with a suffix.
796 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasSuffix)
797 * @param x an array
798 * @param y search suffix
799 * @param fc compare function (a, b)
800 * @param fm map function (v, i, x)
801 * @returns x[|x|-|y|..] = y?
802 */
803declare function hasSuffix<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
804
805/**
806 * Examine if array contains an infix.
807 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasInfix)
808 * @param x an array
809 * @param y search infix
810 * @param fc compare function (a, b)
811 * @param fm map function (v, i, x)
812 * @returns x[i..I] = y for some i, I?
813 */
814declare function hasInfix<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
815/**
816 * Examine if array has a subsequence.
817 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasSubsequence)
818 * @param x an array
819 * @param y search subsequence
820 * @param fc compare function (a, b)
821 * @param fm map function (v, i, x)
822 * @returns x[iโ‚€] โงบ x[iโ‚] โงบ ... = y, for some iโ‚€, iโ‚, ...? | iโ‚€ < iโ‚ < ...
823 */
824declare function hasSubsequence<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
825/**
826 * Examine if array has a permutation.
827 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/hasPermutation)
828 * @param x an array
829 * @param y search permutation
830 * @param fc map function (v, i, x)
831 * @param fm compare function (a, b)
832 * @returns x contains a shuffled version of y?
833 */
834declare function hasPermutation<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
835/**
836 * Obtain all possible prefixes.
837 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/prefixes)
838 * @param x an array
839 * @param n number of values [-1 โ‡’ any]
840 * @returns [[], x[..1], x[..2], ...] if n<0; [x[..n]] otherwise
841 */
842declare function prefixes<T>(x: T[], n?: number): T[][];
843/**
844 * List all possible prefixes.
845 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/iprefixes)
846 * @param x an array
847 * @param n number of values [-1 โ‡’ any]
848 * @returns [], x[..1], x[..2], ... if n<0; x[..n] otherwise
849 */
850declare function iprefixes<T>(x: T[], n?: number): IterableIterator<T[]>;
851/**
852 * Obtain all possible suffixes.
853 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/suffixes)
854 * @param x an array
855 * @param n number of values [-1 โ‡’ any]
856 * @returns [x[0..], x[1..], x[2..], ...] if n<0; [x[-n..]] otherwise
857 */
858declare function suffixes<T>(x: T[], n?: number): T[][];
859/**
860 * List all possible suffixes.
861 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isuffixes)
862 * @param x an array
863 * @param n number of values [-1 โ‡’ any]
864 * @returns x[0..], x[1..], x[2..], ... if n<0; x[-n..] otherwise
865 */
866declare function isuffixes<T>(x: T[], n?: number): IterableIterator<T[]>;
867/**
868 * Obtain all possible infixes.
869 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/infixes)
870 * @param x an array
871 * @param n number of values [-1 โ‡’ any]
872 * @returns [[], x[0..1], x[0..2], ..., x[1..2], ...] if n<0; [only of length n] otherwise
873 */
874declare function infixes<T>(x: T[], n?: number): T[][];
875/**
876 * List all possible infixes.
877 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/iinfixes)
878 * @param x an array
879 * @param n number of values [-1 โ‡’ any]
880 * @returns [], x[0..1], x[0..2], ..., x[1..2], ... if n<0; only of length n otherwise
881 */
882declare function iinfixes<T>(x: T[], n?: number): IterableIterator<T[]>;
883/**
884 * Obtain all possible subsequences.
885 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/subsequences)
886 * @param x an array
887 * @param n number of values [-1 โ‡’ any]
888 * @returns [elements selected by bit from 0..2^|x|] if n<0; [only of length n] otherwise
889 */
890declare function subsequences<T>(x: T[], n?: number): T[][];
891/**
892 * List all possible subsequences.
893 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isubsequences)
894 * @param x an array
895 * @param n number of values [-1 โ‡’ any]
896 * @returns elements selected by bit from 0..2^|x| if n<0; only of length n otherwise
897 */
898declare function isubsequences<T>(x: T[], n?: number): IterableIterator<T[]>;
899/**
900 * Obtain all possible permutations.
901 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/permutations)
902 * @param x an array
903 * @param n number of values [-1 โ‡’ any]
904 * @returns [[], arrangements of length 1, of length 2, ...] if n<0; [only of length n] otherwise
905 */
906declare function permutations<T>(x: T[], n?: number): T[][];
907/**
908 * List all possible permutations.
909 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/ipermutations)
910 * @param x an array
911 * @param n number of values [-1 โ‡’ any]
912 * @returns [], arrangements of length 1, of length 2, ... if n<0; only of length n otherwise
913 */
914declare function ipermutations<T>(x: T[], n?: number): IterableIterator<T[]>;
915/**
916 * Find first index of an infix.
917 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchInfix)
918 * @param x an array
919 * @param y search infix
920 * @param fc compare function (a, b)
921 * @param fm map function (v, i, x)
922 * @returns first i | x[i..i+|y|] = y else -1
923 */
924declare function searchInfix<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
925/**
926 * Find last index of an infix.
927 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchInfixRight)
928 * @param x an array
929 * @param y search infix
930 * @param fc compare function (a, b)
931 * @param fm map function (v, i, x)
932 * @returns first i | x[i..i+|y|] = y else -1
933 */
934declare function searchInfixRight<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
935/**
936 * Find indices of an infix.
937 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchInfixAll)
938 * @param x an array
939 * @param y search infix
940 * @param fc compare function (a, b)
941 * @param fm map function (v, i, x)
942 * @returns iโ‚€, iโ‚, ... | x[j..j+|y|] = y; j โˆˆ [iโ‚€, iโ‚, ...]
943 */
944declare function searchInfixAll<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number[];
945/**
946 * Find first index of a subsequence.
947 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchSubsequence)
948 * @param x an array
949 * @param y search subsequence
950 * @param fc compare function (a, b)
951 * @param fm map function (v, i, x)
952 * @returns begin index of subsequence, -1 if not found
953 */
954declare function searchSubsequence<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): number;
955/**
956 * Pick an arbitrary value.
957 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomValue)
958 * @param x an array
959 * @param fr random number generator ([0, 1))
960 * @returns x[i] | i โˆˆ 0..|x|
961 */
962declare function randomValue<T>(x: T[], fr?: ReadFunction<number> | null): T;
963
964/**
965 * Pick an arbitrary prefix.
966 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomPrefix)
967 * @param x an array
968 * @param n number of values [-1 โ‡’ any]
969 * @param fr random number generator ([0, 1))
970 * @returns x[..i] if n<0; x[..n] otherwise | i โˆˆ 0..|x|
971 */
972declare function randomPrefix<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
973
974/**
975 * Pick an arbitrary suffix.
976 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomSuffix)
977 * @param x an array
978 * @param n number of values [-1 โ‡’ any]
979 * @param fr random number generator ([0, 1))
980 * @returns x[|x|-i..] if n<0; x[|x|-n..] otherwise | i โˆˆ 0..|x|
981 */
982declare function randomSuffix<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
983
984/**
985 * Pick an arbitrary infix.
986 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomInfix)
987 * @param x an array
988 * @param n number of values [-1 โ‡’ any]
989 * @param fr random number generator ([0, 1))
990 * @returns x[i..j] if n<0; x[i..i+n] otherwise | i, j โˆˆ 0..|x|
991 */
992declare function randomInfix<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
993
994/**
995 * Pick an arbitrary subsequence.
996 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomSubsequence)
997 * @param x an array
998 * @param n number of values [-1 โ‡’ any]
999 * @param fr random number generator ([0, 1))
1000 * @returns x[i, j, ...] | [i, j, ...] = is; |is| = |x| if n<0 else n
1001 */
1002declare function randomSubsequence<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
1003
1004/**
1005 * Pick an arbitrary permutation.
1006 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomPermutation)
1007 * @param x an array
1008 * @param n number of values [-1 โ‡’ any]
1009 * @param fr random number generator ([0, 1))
1010 * @returns x' | x' = x; values are randomly shuffled
1011 */
1012declare function randomPermutation<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
1013
1014/**
1015 * Pick an arbitrary permutation!
1016 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/randomPermutation$)
1017 * @param x an array (updated!)
1018 * @param n number of values [-1 โ‡’ any]
1019 * @param fr random number generator ([0, 1))
1020 * @returns x | values are randomly shuffled
1021 */
1022declare function randomPermutation$<T>(x: T[], n?: number, fr?: ReadFunction<number> | null): T[];
1023
1024/**
1025 * Find first value passing a test.
1026 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/find)
1027 * @param x an array
1028 * @param ft test function (v, i, x)
1029 * @returns first v | ft(v) = true; v โˆˆ x
1030 */
1031declare function find<T>(x: T[], ft: TestFunction<T>): T;
1032/**
1033 * Find last value passing a test.
1034 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/findRight)
1035 * @param x an array
1036 * @param ft test function (v, i, x)
1037 * @returns last v | ft(v) = true; v โˆˆ x
1038 */
1039declare function findRight<T>(x: T[], ft: TestFunction<T>): T;
1040/**
1041 * Keep first n values only.
1042 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/take)
1043 * @param x an array
1044 * @param n number of values [1]
1045 * @returns x[0..n]
1046 */
1047declare function take<T>(x: T[], n?: number): T[];
1048
1049/**
1050 * Keep last n values only.
1051 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/takeRight)
1052 * @param x an array
1053 * @param n number of values [1]
1054 * @returns x[0..n]
1055 */
1056declare function takeRight<T>(x: T[], n?: number): T[];
1057
1058/**
1059 * Keep values from left, while a test passes.
1060 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/takeWhile)
1061 * @param x an array
1062 * @param ft test function (v, i, x)
1063 * @returns x[0..T-1] | ft(x[i]) = true โˆ€ i โˆˆ [0, T-1] & ft(x[T]) = false
1064 */
1065declare function takeWhile<T>(x: T[], ft: TestFunction<T>): T[];
1066/**
1067 * Keep values from right, while a test passes.
1068 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/takeWhileRight)
1069 * @param x an array
1070 * @param ft test function (v, i, x)
1071 * @returns x[T..] | ft(x[i]) = true โˆ€ i โˆˆ [T, |x|-1] & ft(x[T-1]) = false
1072 */
1073declare function takeWhileRight<T>(x: T[], ft: TestFunction<T>): T[];
1074/**
1075 * Discard first n values only.
1076 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/drop)
1077 * @param x an array
1078 * @param n number of values [1]
1079 * @returns x[n..]
1080 */
1081declare function drop<T>(x: T[], n?: number): T[];
1082/**
1083 * Discard last n values only.
1084 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/dropRight)
1085 * @param x an array
1086 * @param n number of values [1]
1087 * @returns x[0..-n]
1088 */
1089declare function dropRight<T>(x: T[], n?: number): T[];
1090/**
1091 * Discard values from left, while a test passes.
1092 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/dropWhile)
1093 * @param x an array
1094 * @param ft test function (v, i, x)
1095 * @returns x[T..] | ft(x[i]) = true โˆ€ i โˆˆ [0, T-1] & ft(x[T]) = false
1096 */
1097declare function dropWhile<T>(x: T[], ft: TestFunction<T>): T[];
1098/**
1099 * Discard values from right, while a test passes.
1100 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/dropWhileRight)
1101 * @param x an array
1102 * @param ft test function (v, i, x)
1103 * @returns x[0..T-1] | ft(x[i]) = true โˆ€ i โˆˆ [T, |x|-1] & ft(x[T-1]) = false
1104 */
1105declare function dropWhileRight<T>(x: T[], ft: TestFunction<T>): T[];
1106/**
1107 * Scan from left, while a test passes.
1108 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/scanWhile)
1109 * @param x an array
1110 * @param ft test function (v, i, x)
1111 * @returns first index where test fails
1112 */
1113declare function scanWhile<T>(x: T[], ft: TestFunction<T>): number;
1114/**
1115 * Scan from right, while a test passes.
1116 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/scanWhileRight)
1117 * @param x an array
1118 * @param ft test function (v, i, x)
1119 * @returns first index where test passes till end
1120 */
1121declare function scanWhileRight<T>(x: T[], ft: TestFunction<T>): number;
1122/**
1123 * Scan from left, until a test passes.
1124 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/scanUntil)
1125 * @param x an array
1126 * @param ft test function (v, i, x)
1127 * @returns first index where test passes
1128 */
1129declare function scanUntil<T>(x: T[], ft: TestFunction<T>): number;
1130/**
1131 * Scan from right, until a test passes.
1132 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/scanUntilRight)
1133 * @param x an array
1134 * @param ft test function (v, i, x)
1135 * @returns first index where test fails till end
1136 */
1137declare function scanUntilRight<T>(x: T[], ft: TestFunction<T>): number;
1138/**
1139 * Find first index of a value.
1140 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/indexOf)
1141 * @param x an array
1142 * @param v search value
1143 * @param i begin index [0]
1144 * @returns index of v in x[i..] if found else -1
1145 */
1146declare function indexOf<T>(x: T[], v: T, i?: number): number;
1147/**
1148 * Find last index of a value.
1149 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/lastIndexOf)
1150 * @param x an array
1151 * @param v search value
1152 * @param i begin index [|x|-1]
1153 * @returns last index of v in x[0..i] if found else -1
1154 */
1155declare function lastIndexOf<T>(x: T[], v: T, i?: number): number;
1156/**
1157 * Find index of first value passing a test.
1158 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/search)
1159 * @param x an array
1160 * @param ft test function (v, i, x)
1161 * @returns first index of value, -1 if not found
1162 */
1163declare function search<T>(x: T[], ft: TestFunction<T>): number;
1164
1165/**
1166 * Find index of last value passing a test.
1167 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchRight)
1168 * @param x an array
1169 * @param ft test function (v, i, x)
1170 * @returns last index of value, -1 if not found
1171 */
1172declare function searchRight<T>(x: T[], ft: TestFunction<T>): number;
1173
1174/**
1175 * Find indices of values passing a test.
1176 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/searchAll)
1177 * @param x an array
1178 * @param ft test function (v, i, x)
1179 * @returns indices of value
1180 */
1181declare function searchAll<T>(x: T[], ft: TestFunction<T>): number[];
1182/**
1183 * Call a function for each value.
1184 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/forEach)
1185 * @param x an array
1186 * @param fp process function (v, i, x)
1187 */
1188declare function forEach<T>(x: T[], fp: ProcessFunction<T>): void;
1189/**
1190 * Examine if any value satisfies a test.
1191 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/some)
1192 * @param x an array
1193 * @param ft test function (v, i, x)
1194 * @returns true if ft(vแตข) = true for some vแตข โˆˆ x
1195 */
1196declare function some<T>(x: T[], ft?: TestFunction<T> | null): boolean;
1197
1198/**
1199 * Examine if all values satisfy a test.
1200 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/every)
1201 * @param x an array
1202 * @param ft test function (v, i, x)
1203 * @returns true if ft(vแตข) = true for all vแตข โˆˆ x
1204 */
1205declare function every<T>(x: T[], ft?: TestFunction<T> | null): boolean;
1206
1207/**
1208 * Transform values of an array.
1209 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/map)
1210 * @param x an array
1211 * @param fm map function (v, i, x)
1212 * @returns [fm(vโ‚€), fm(vโ‚), ...] | vแตข โˆˆ x
1213 */
1214declare function map<T, U = T>(x: T[], fm: MapFunction<T, T | U>): (T | U)[];
1215/**
1216 * Transform values of an array!
1217 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/map$)
1218 * @param x an array (updated!)
1219 * @param fm map function (v, i, x)
1220 * @returns x = [fm(vโ‚€), fm(vโ‚), ...]; vแตข โˆˆ x
1221 */
1222declare function map$<T>(x: T[], fm: MapFunction<T, T>): T[];
1223/**
1224 * Reduce values of array to a single value.
1225 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reduce)
1226 * @param x an array
1227 * @param fr reduce function (acc, v, i, x)
1228 * @param acc initial value
1229 * @returns fr(fr(acc, vโ‚€), vโ‚)... | fr(acc, vโ‚€) = vโ‚€ if acc not given
1230 */
1231declare function reduce<T, U = T>(x: T[], fr: ReduceFunction<T, T | U>, acc?: T | U): T | U;
1232/**
1233 * Reduce values from right, to a single value.
1234 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reduceRight)
1235 * @param x an array
1236 * @param fr reduce function (acc, v, i, x)
1237 * @param acc initial value
1238 * @returns fr(fr(acc, vโ‚“โ‚‹โ‚€), vโ‚“โ‚‹โ‚)... | fr(acc, vโ‚“โ‚‹โ‚€) = vโ‚“โ‚‹โ‚€ if acc not given
1239 */
1240declare function reduceRight<T, U = T>(x: T[], fr: ReduceFunction<T, T | U>, acc?: T | U): T | U;
1241/**
1242 * Keep values which pass a test.
1243 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/filter)
1244 * @param x an array
1245 * @param ft test function (v, i, x)
1246 * @returns [vโ‚€, vโ‚, ...] | ft(vแตข) = true; vแตข โˆˆ x
1247 */
1248declare function filter<T>(x: T[], ft: TestFunction<T>): T[];
1249
1250/**
1251 * Keep values which pass a test!
1252 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/filter$)
1253 * @param x an array (updated!)
1254 * @param ft test function (v, i, x)
1255 * @returns x = [vโ‚€, vโ‚, ...] | ft(vแตข) = true; vแตข โˆˆ x
1256 */
1257declare function filter$<T>(x: T[], ft: TestFunction<T>): T[];
1258/**
1259 * Keep values at given indices.
1260 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/filterAt)
1261 * @param x an array
1262 * @param is indices
1263 * @returns vโ‚€, vโ‚, ... | vแตข = x[i]; i โˆˆ is
1264 */
1265declare function filterAt<T>(x: T[], is: number[]): T[];
1266/**
1267 * Discard values which pass a test.
1268 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reject)
1269 * @param x an array
1270 * @param ft test function (v, i, x)
1271 * @returns [vโ‚€, vโ‚, ...] | ft(vแตข) = false; vแตข โˆˆ x
1272 */
1273declare function reject<T>(x: T[], ft: TestFunction<T>): T[];
1274/**
1275 * Discard values which pass a test!
1276 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reject$)
1277 * @param x an array (updated!)
1278 * @param ft test function (v, i, x)
1279 * @returns x = [vโ‚€, vโ‚, ...] | ft(vแตข) = false; vแตข โˆˆ x
1280 */
1281declare function reject$<T>(x: T[], ft: TestFunction<T>): T[];
1282/**
1283 * Discard values at given indices.
1284 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rejectAt)
1285 * @param x an array
1286 * @param is indices
1287 * @returns [vโ‚€, vโ‚, ...] | vแตข = x[i]; i โˆ‰ is
1288 */
1289declare function rejectAt<T>(x: T[], is: number[]): T[];
1290/**
1291 * Flatten nested array to given depth.
1292 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/flat)
1293 * @param x a nested array
1294 * @param n maximum depth [-1 โ‡’ all]
1295 * @param fm map function (v, i, x)
1296 * @param ft flatten test function (v, i, x) [is]
1297 * @returns flat iterable
1298 */
1299declare function flat(x: any[], n?: number, fm?: MapFunction<any, any> | null, ft?: TestFunction<any> | null): any[];
1300/**
1301 * Flatten nested array, based on map function.
1302 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/flatMap)
1303 * @param x an array
1304 * @param fm map function (v, i, x)
1305 * @param ft flatten test function (v, i, x) [is]
1306 * @returns flat iterable
1307 */
1308declare function flatMap(x: any[], fm?: MapFunction<any, any> | null, ft?: TestFunction<any> | null): any[];
1309/**
1310 * Perform exclusive prefix scan from left to right.
1311 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/exclusiveScan)
1312 * @param x an array
1313 * @param fr reduce function (acc, v, i, x)
1314 * @param acc initial value
1315 * @returns [acc, fr(acc, vโ‚€), fr(fr(acc, vโ‚€), vโ‚)...]
1316 */
1317declare function exclusiveScan<T, U = T>(x: T[], fr: ReduceFunction<T, T | U>, acc: T | U): (T | U)[];
1318/**
1319 * Perform exclusive prefix scan from left to right!
1320 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/exclusiveScan$)
1321 * @param x an array (updated!)
1322 * @param fr reduce function (acc, v, i, x)
1323 * @param acc initial value
1324 * @returns x = [acc, fr(acc, vโ‚€), fr(fr(acc, vโ‚€), vโ‚)...]
1325 */
1326declare function exclusiveScan$<T>(x: T[], fr: ReduceFunction<T, T>, acc: T): T[];
1327/**
1328 * Perform inclusive prefix scan from left to right.
1329 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/inclusiveScan)
1330 * @param x an array
1331 * @param fr reduce function (acc, v, i, x)
1332 * @param acc initial value
1333 * @returns [fr(acc, vโ‚€), fr(fr(acc, vโ‚€), vโ‚)...]
1334 */
1335declare function inclusiveScan<T, U = T>(x: T[], fr: ReduceFunction<T, T | U>, acc?: T | U): (T | U)[];
1336
1337/**
1338 * Perform inclusive prefix scan from left to right!
1339 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/inclusiveScan$)
1340 * @param x an array (updated!)
1341 * @param fr reduce function (acc, v, i, x)
1342 * @param acc initial value
1343 * @returns x = [fr(acc, vโ‚€), fr(fr(acc, vโ‚€), vโ‚)...]
1344 */
1345declare function inclusiveScan$<T>(x: T[], fr: ReduceFunction<T, T>, acc: T): T[];
1346/**
1347 * Combine adjacent values of an array.
1348 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/adjacentCombine)
1349 * @param x an array
1350 * @param fc combine function (u, v)
1351 * @param acc initial value
1352 * @returns [fc(acc, vโ‚€), fc(vโ‚€, vโ‚)...] | vแตข โˆˆ x
1353 */
1354declare function adjacentCombine<T>(x: T[], fc: CombineFunction<T>, acc: T): T[];
1355/**
1356 * Combine adjacent values of an array!
1357 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/adjacentCombine$)
1358 * @param x an array (updated!)
1359 * @param fc combine function (u, v)
1360 * @param acc initial value
1361 * @returns x = [fc(acc, vโ‚€), fc(vโ‚€, vโ‚)...] | vแตข โˆˆ x
1362 */
1363declare function adjacentCombine$<T>(x: T[], fc: CombineFunction<T>, acc: T): T[];
1364/**
1365 * Place a separator between every value.
1366 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/intersperse)
1367 * @param x an array
1368 * @param v separator
1369 * @returns [x[0], v, x[1], v, ..., x[|x|-1]]
1370 */
1371declare function intersperse<T>(x: T[], v: T): T[];
1372/**
1373 * Estimate new values between existing ones.
1374 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/interpolate)
1375 * @param x an array
1376 * @param fc combine function (a, b)
1377 * @returns [x[0], fc(x[0], x[1]), x[1], fc(x[1], x[2]), ..., x[|x|-1]]
1378 */
1379declare function interpolate<T>(x: T[], fc: CombineFunction<T>): T[];
1380/**
1381 * Place values of an array between another.
1382 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/intermix)
1383 * @param x an array
1384 * @param y another array
1385 * @param m number of values from x [1]
1386 * @param n number of values from y [1]
1387 * @param s step size for x [m]
1388 * @param t step size for y [n]
1389 * @returns x[0..m] โงบ y[0..n] โงบ x[s..s+m] โงบ y[t..t+n] โงบ ... โงบ x[k*s..|x|-1] | k โˆˆ W
1390 */
1391declare function intermix<T>(x: T[], y: T[], m?: number, n?: number, s?: number, t?: number): T[];
1392/**
1393 * Place values from iterables alternately.
1394 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/interleave)
1395 * @param xs arrays
1396 * @returns [xโ‚€[0], xโ‚[0], ..., xโ‚€[1], xโ‚[0], ...] | [xโ‚€, xโ‚, ...] = xs
1397 */
1398declare function interleave<T>(xs: T[][]): T[];
1399/**
1400 * Combine values from arrays.
1401 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/zip)
1402 * @param xs arrays
1403 * @param fm map function (vs, i)
1404 * @param fe end function (dones) [some]
1405 * @param vd default value
1406 * @returns [fm([xโ‚€[0], xโ‚[0], ...]), fm([xโ‚€[1], xโ‚[1], ...]), ...]
1407 */
1408declare function zip<T, U = T[]>(xs: T[][], fm?: MapFunction<T[], T[] | U> | null, fe?: EndFunction, vd?: T): (T[] | U)[];
1409/**
1410 * Fill with given value.
1411 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fill)
1412 * @param x an array
1413 * @param v value
1414 * @param i begin index [0]
1415 * @param I end index [|x|]
1416 * @returns x' | x' = x; x'[i..I] = v
1417 */
1418declare function fill<T>(x: T[], v: T, i?: number, I?: number): T[];
1419/**
1420 * Fill with given value!
1421 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/fill$)
1422 * @param x an array (updated!)
1423 * @param v value
1424 * @param i begin index [0]
1425 * @param I end index [|x|]
1426 * @returns x | x[i..I] = v
1427 */
1428declare function fill$<T>(x: T[], v: T, i?: number, I?: number): T[];
1429/**
1430 * Add value to the end.
1431 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/push)
1432 * @param x an array
1433 * @param vs values to add
1434 * @returns x โงบ vs
1435 */
1436declare function push<T>(x: T[], ...vs: T[]): T[];
1437
1438/**
1439 * Add values to the end!
1440 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/push$)
1441 * @param x an array (updated!)
1442 * @param vs values to add
1443 * @returns x = x โงบ vs
1444 */
1445declare function push$<T>(x: T[], ...vs: T[]): T[];
1446
1447/**
1448 * Remove last value.
1449 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/pop)
1450 * @param x an array
1451 * @returns x[0..|x|-1]
1452 */
1453declare function pop<T>(x: T[]): T[];
1454
1455/**
1456 * Remove last value!
1457 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/pop$)
1458 * @param x an array (updated!)
1459 * @returns x = x[0..|x|-1]
1460 */
1461declare function pop$<T>(x: T[]): T[];
1462
1463/**
1464 * Remove first value.
1465 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/shift)
1466 * @param x an array
1467 * @returns x[1..]
1468 */
1469declare function shift<T>(x: T[]): T[];
1470
1471/**
1472 * Remove first value!
1473 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/shift$)
1474 * @param x an array (updated!)
1475 * @returns x = x[1..]
1476 */
1477declare function shift$<T>(x: T[]): T[];
1478
1479/**
1480 * Add values to the start.
1481 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/unshift)
1482 * @param x an array
1483 * @param vs values to add
1484 * @returns vs โงบ x
1485 */
1486declare function unshift<T>(x: Iterable<T>, ...vs: T[]): T[];
1487
1488/**
1489 * Add values to the start!
1490 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/unshift$)
1491 * @param x an array (updated!)
1492 * @param vs values to add
1493 * @returns x = vs โงบ x
1494 */
1495declare function unshift$<T>(x: T[], ...vs: T[]): T[];
1496
1497/**
1498 * Copy part of array to another.
1499 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/copy)
1500 * @param x target array
1501 * @param y source array
1502 * @param j write index [0]
1503 * @param i read begin index [0]
1504 * @param I read end index [|x|]
1505 * @returns x[0..j] โงบ y[i..I] โงบ x[j+I-i..]
1506 */
1507declare function copy<T>(x: T[], y: T[], j?: number, i?: number, I?: number): T[];
1508/**
1509 * Copy part of array to another!
1510 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/copy$)
1511 * @param x target array (updated!)
1512 * @param y source array
1513 * @param j write index [0]
1514 * @param i read begin index [0]
1515 * @param I read end index [|x|]
1516 * @returns x = x[0..j] โงบ y[i..I] โงบ x[j+I-i..]
1517 */
1518declare function copy$<T>(x: T[], y: T[], j?: number, i?: number, I?: number): T[];
1519/**
1520 * Copy part of array within.
1521 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/copyWithin)
1522 * @param x an array
1523 * @param j write index [0]
1524 * @param i read begin index [0]
1525 * @param I read end index [|x|]
1526 * @returns x[0..j] โงบ x[i..I] โงบ x[j+I-i..]
1527 */
1528declare function copyWithin<T>(x: T[], j?: number, i?: number, I?: number): T[];
1529/**
1530 * Copy part of array within!
1531 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/copyWithin$)
1532 * @param x an array (updated!)
1533 * @param j write index [0]
1534 * @param i read begin index [0]
1535 * @param I read end index [|x|]
1536 * @returns x = x[0..j] โงบ x[i..I] โงบ x[j+I-i..]
1537 */
1538declare function copyWithin$<T>(x: T[], j?: number, i?: number, I?: number): T[];
1539/**
1540 * Move part of array within.
1541 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/moveWithin)
1542 * @param x an array
1543 * @param j write index [0]
1544 * @param i read begin index [0]
1545 * @param I read end index [|x|]
1546 * @returns x[0..j] โงบ x[i..I] โงบ x[j..i] โงบ x[I..]
1547 */
1548declare function moveWithin<T>(x: T[], j?: number, i?: number, I?: number): T[];
1549/**
1550 * Move part of array within!
1551 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/moveWithin$)
1552 * @param x an array (updated!)
1553 * @param j write ยฑindex [0]
1554 * @param i read begin ยฑindex [0]
1555 * @param I read end ยฑindex [|x|]
1556 * @returns x = x[0..j] โงบ x[i..I] โงบ x[j..i] โงบ x[I..]
1557 */
1558declare function moveWithin$<T>(x: T[], j?: number, i?: number, I?: number): T[];
1559/**
1560 * Remove or replace existing values.
1561 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/splice)
1562 * @param x an array
1563 * @param i remove ยฑindex
1564 * @param n number of values to remove [rest]
1565 * @param vs values to insert
1566 * @returns x[0..i] โงบ vs โงบ x[i+n..]
1567 */
1568declare function splice<T>(x: T[], i: number, n?: number, ...vs: T[]): T[];
1569
1570/**
1571 * Remove or replace existing values!
1572 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/splice$)
1573 * @param x an array (updated!)
1574 * @param i remove ยฑindex
1575 * @param n number of values to remove [rest]
1576 * @param vs values to insert
1577 * @returns x = x[0..i] โงบ vs โงบ x[i+n..]
1578 */
1579declare function splice$<T>(x: T[], i: number, n?: number, ...vs: T[]): T[];
1580/**
1581 * Count values which satisfy a test.
1582 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/count)
1583 * @param x an array
1584 * @param ft test function (v, i, x)
1585 * @returns ฮฃtแตข | tแตข = 1 if ft(vแตข) else 0; vแตข โˆˆ x
1586 */
1587declare function count<T>(x: T[], ft: TestFunction<T>): number;
1588/**
1589 * Count occurrences of each distinct value.
1590 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/countEach)
1591 * @param x an array
1592 * @param fm map function (v, i, x)
1593 * @returns Map \{value โ‡’ count\}
1594 */
1595declare function countEach<T, U = T>(x: T[], fm?: MapFunction<T, T | U> | null): Map<T | U, number>;
1596
1597/**
1598 * Segregate values by test result.
1599 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/partition)
1600 * @param x an array
1601 * @param ft test function (v, i, x)
1602 * @returns [satisfies, doesnt]
1603 */
1604declare function partition<T>(x: T[], ft: TestFunction<T>): [T[], T[]];
1605/**
1606 * Segregate each distinct value.
1607 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/partitionEach)
1608 * @param x an array
1609 * @param fm map function (v, i, x)
1610 * @returns Map \{key โ‡’ values\}
1611 */
1612declare function partitionEach<T, U = T>(x: T[], fm?: MapFunction<T, T | U> | null): Map<T | U, T[]>;
1613
1614/**
1615 * Break array considering test as separator.
1616 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/split)
1617 * @param x an array
1618 * @param ft test function (v, i, x)
1619 * @returns [x[j..k], x[l..m], ...] | ft(x[i]) = true; i = 0..j / k..l / ...
1620 */
1621declare function split<T>(x: T[], ft: TestFunction<T>): T[][];
1622/**
1623 * Break array considering indices as separator.
1624 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/splitAt)
1625 * @param x an array
1626 * @param is indices (sorted)
1627 * @returns [x[j..k], x[l..m], ...] | ft(x[i]) = true; i = 0..j / k..l / ...; i โˆˆ is
1628 */
1629declare function splitAt<T>(x: T[], is: number[]): T[][];
1630/**
1631 * Break array when test passes.
1632 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cut)
1633 * @param x an array
1634 * @param ft test function (v, i, x)
1635 * @returns [x[0..j], x[j..k], ...] | ft(x[i]) = true; i = j, k, ...
1636 */
1637declare function cut<T>(x: T[], ft: TestFunction<T>): T[][];
1638/**
1639 * Break array after test passes.
1640 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cutRight)
1641 * @param x an array
1642 * @param ft test function (v, i, x)
1643 * @returns [x[0..j+1], x[j+1..k], ...] | ft(x[i]) = true; i = j, k, ...
1644 */
1645declare function cutRight<T>(x: T[], ft: TestFunction<T>): T[][];
1646/**
1647 * Break array at given indices.
1648 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cutAt)
1649 * @param x an array
1650 * @param is split ยฑindices (left to right)
1651 * @returns [x[0..j], x[j..k], ...] | ft(x[i]) = true; i = j, k, ...; i โˆˆ is
1652 */
1653declare function cutAt<T>(x: T[], is: number[]): T[][];
1654/**
1655 * Break array after given indices.
1656 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cutAtRight)
1657 * @param x an array
1658 * @param is split ยฑindices (left to right)
1659 * @returns [x[0..j+1], x[j+1..k], ...] | ft(x[i]) = true; i = j, k, ...; i โˆˆ is
1660 */
1661declare function cutAtRight<T>(x: T[], is: number[]): T[][];
1662/**
1663 * Keep similar values together and in order.
1664 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/group)
1665 * @param x an array
1666 * @param fc compare function (a, b)
1667 * @param fm map function (v, i, x)
1668 * @returns [x[0..k], x[k..l], ...] | fc(x[i], x[j]) = 0; i, j = 0..k / k..l / ...
1669 */
1670declare function group<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[][];
1671/**
1672 * Break array into chunks of given size.
1673 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/chunk)
1674 * @param x an array
1675 * @param n chunk size [1]
1676 * @param s chunk step [n]
1677 * @returns x[0..n] โงบ x[s..s+n] โงบ x[2s..2s+n] โงบ ...
1678 */
1679declare function chunk<T>(x: T[], n?: number, s?: number): T[][];
1680/**
1681 * Append values from arrays.
1682 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/concat)
1683 * @param xs arrays
1684 * @returns xโ‚€ โงบ xโ‚ โงบ ... | [xโ‚€, xโ‚, ...] = xs
1685 */
1686declare function concat<T>(...xs: T[][]): T[];
1687/**
1688 * Append values from arrays!
1689 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/concat$)
1690 * @param x an array (updated!)
1691 * @param ys arrays to append
1692 * @returns x = x โงบ yโ‚€ โงบ yโ‚ โงบ ...] | [yโ‚€, yโ‚, ...] = ys
1693 */
1694declare function concat$<T>(x: T[], ...ys: Iterable<T>[]): T[];
1695/**
1696 * Join values together into a string.
1697 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/join)
1698 * @param x an array
1699 * @param sep separator [,]
1700 * @returns "$\{vโ‚€\}$\{sep\}$\{vโ‚\}..." | vแตข โˆˆ x
1701 */
1702declare function join<T>(x: T[], sep?: string): string;
1703/**
1704 * Obtain values that cycle through array.
1705 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cycle)
1706 * @param x an array
1707 * @param i begin ยฑindex [0]
1708 * @param n number of values [|x|]
1709 */
1710declare function cycle<T>(x: T[], i?: number, n?: number): T[];
1711/**
1712 * Repeat an array given times.
1713 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/repeat)
1714 * @param x an array
1715 * @param n times [1]
1716 * @returns x โงบ x โงบ ...(n times)
1717 */
1718declare function repeat<T>(x: T[], n?: number): T[];
1719/**
1720 * Reverse the values.
1721 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reverse)
1722 * @param x an array
1723 * @returns [x[|x|-1], x[|x|-2], ..., x[1], x[0]]
1724 */
1725declare function reverse<T>(x: T[]): T[];
1726
1727/**
1728 * Reverse the values!
1729 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/reverse$)
1730 * @param x an array (updated!)
1731 * @returns x = [x[|x|-1], x[|x|-2], ..., x[1], x[0]]
1732 */
1733declare function reverse$<T>(x: T[]): T[];
1734/**
1735 * Rotate values in array.
1736 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rotate)
1737 * @param x an array
1738 * @param n rotate amount (+ve: left, -ve: right) [0]
1739 * @returns x[n..] โงบ x[0..n]
1740 */
1741declare function rotate<T>(x: T[], n?: number): T[];
1742/**
1743 * Rotate values in array!
1744 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/rotate$)
1745 * @param x an array (updated!)
1746 * @param n rotate amount (+ve: left, -ve: right) [0]
1747 * @returns x = x[n..] โงบ x[0..n]
1748 */
1749declare function rotate$<T>(x: T[], n?: number): T[];
1750/**
1751 * Examine if there are no duplicate values.
1752 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isUnique)
1753 * @param x an array
1754 * @param fc compare function (a, b)
1755 * @param fm map function (v, i, x)
1756 * @returns โˆ€ vแตข, vโฑผ โˆˆ x, is vแตข โ‰  vโฑผ?
1757 */
1758declare function isUnique<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
1759/**
1760 * Examine if arrays have no value in common.
1761 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/isDisjoint)
1762 * @param x an array
1763 * @param y another array
1764 * @param fc compare function (a, b)
1765 * @param fm map function (v, i, x)
1766 * @returns x โˆฉ y = ฮฆ?
1767 */
1768declare function isDisjoint<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): boolean;
1769/**
1770 * Remove duplicate values.
1771 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/unique)
1772 * @param x an array
1773 * @param fc compare function (a, b)
1774 * @param fm map function (v, i, x)
1775 * @returns vโ‚€, vโ‚, ... | vแตข โˆˆ x; vแตข โ‰  vโฑผ โˆ€ i, j
1776 */
1777declare function unique<T, U = T>(x: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1778/**
1779 * Obtain values present in any array.
1780 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/union)
1781 * @param x an array
1782 * @param y another array
1783 * @param fc compare function (a, b)
1784 * @param fm map function (v, i, x)
1785 * @returns x โˆช y = \{v | v โˆˆ x or v โˆˆ y\}
1786 */
1787declare function union<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1788/**
1789 * Obtain values present in any array!
1790 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/union$)
1791 * @param x an array (updated!)
1792 * @param y another array
1793 * @param fc compare function (a, b)
1794 * @param fm map function (v, i, x)
1795 * @returns x = x โˆช y = \{v | v โˆˆ x or v โˆˆ y\}
1796 */
1797declare function union$<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1798/**
1799 * Obtain values present in both arrays.
1800 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/intersection)
1801 * @param x an array
1802 * @param y another array
1803 * @param fc compare function (a, b)
1804 * @param fm map function (v, i, x)
1805 * @returns x โˆฉ y = \{v | v โˆˆ x, v โˆˆ y\}
1806 */
1807declare function intersection<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1808/**
1809 * Obtain values not present in another array.
1810 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/difference)
1811 * @param x an array
1812 * @param y another array
1813 * @param fc compare function (a, b)
1814 * @param fm map function (v, i, x)
1815 * @returns x - y = \{v | v โˆˆ x, v โˆ‰ y\}
1816 */
1817declare function difference<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1818/**
1819 * Obtain values not present in both arrays.
1820 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/symmetricDifference)
1821 * @param x an array
1822 * @param y another array
1823 * @param fc compare function (a, b)
1824 * @param fm map function (v, i, x)
1825 * @returns x-y โˆช y-x
1826 */
1827declare function symmetricDifference<T, U = T>(x: T[], y: T[], fc?: CompareFunction<T | U> | null, fm?: MapFunction<T, T | U> | null): T[];
1828/**
1829 * Obtain cartesian product of arrays.
1830 * [๐Ÿ“˜](https://github.com/nodef/extra-array/wiki/cartesianProduct)
1831 * @param xs arrays
1832 * @param fm map function (vs, i)
1833 * @returns xโ‚€ ร— xโ‚ ร— ... = \{[vโ‚€, vโ‚, ...] | vโ‚€ โˆˆ xโ‚€, vโ‚ โˆˆ xโ‚, ...] \}
1834 */
1835declare function cartesianProduct<T, U = T>(xs: T[][], fm?: MapFunction<T[], T[] | U> | null): (T[] | U)[];
1836
1837export { type CombineFunction, type CompareFunction, type EndFunction, type Entries, type IEntries, type ILists, type Lists, type MapFunction, type ProcessFunction, type ReadFunction, type ReduceFunction, type SwapFunction, type TestFunction, inclusiveScan as accumulate, adjacentCombine, adjacentCombine$, every as allOf, some as anyOf, push as append, push$ as append$, get as at, last as back, cartesianProduct, chunk, clear$, shallowClone as clone, compare, concat, concat$, copy, copy$, copyWithin, copyWithin$, count, countEach as countAs, countEach, cut, cutAt, cutAtRight, cutRight, cycle, deepClone, difference, drop, dropRight, dropWhile, dropWhileRight, hasSuffix as endsWith, entries, every, exclusiveScan, exclusiveScan$, fill, fill$, filter, filter$, filterAt, find, filter as findAll, search as findIndex, searchRight as findLastIndex, findRight, head as first, flat, flatMap, forEach, fromIterable as from, fromIterable$ as from$, fromApplication, fromApplication as fromApply, fromInvocation as fromCall, fromInvocation, fromIterable, fromIterable$, fromRange, head as front, get, getAll, getPath, group, partitionEach as groupToMap, hasInfix, hasPath, hasPermutation, hasPrefix, hasSubsequence, hasSuffix, hasUnsortedValue, hasValue, head, ientries, iinfixes, ikeys, includes, inclusiveScan, inclusiveScan$, index, indexOf, indexRange, randomInfix as infix, infixes, init, interleave, intermix, interpolate, intersection, intersperse, ipermutations, iprefixes, is, isDisjoint, isEmpty, isEqual, isSorted, isUnique, isubsequences, isuffixes, ivalues, join, keys, last, lastIndexOf, take as left, length, map, map$, maximum as max, maximumEntry as maxEntry, maximum, maximumEntries, maximumEntry, maximums, middle, minimum as min, minimumEntry as minEntry, minimum, minimumEntries, minimumEntry, minimums, moveWithin, moveWithin$, partialSort, partialSort$, partition, partitionEach as partitionAs, partitionEach, randomPermutation as permutation, randomPermutation$ as permutation$, permutations, randomPermutation$ as permute$, pop, pop$, pop as popBack, pop as popBack$, shift as popFront, shift$ as popFront$, randomPrefix as prefix, prefixes, unshift as prepend, unshift$ as prepend$, push, push$, push as pushBack, push$ as pushBack$, unshift as pushFront, unshift$ as pushFront$, randomInfix, randomPermutation, randomPermutation$, randomPrefix, randomSubsequence, randomSuffix, randomValue, range, rangeEntries, rangedPartialSort, rangedPartialSort$, rangedSort, rangedSort$, reduce, reduceRight, reject, reject$, rejectAt, remove, remove$, removePath$, repeat, resize$, reverse, reverse$, takeRight as right, rotate, rotate$, scanUntil, scanUntilRight, scanWhile, scanWhileRight, search, searchAdjacentDuplicateValue as searchAdjacentDuplicate, searchAdjacentDuplicateValue, searchAll, searchInfix, searchInfixAll, searchInfixRight, searchMaximumValue, searchMaximumValues, searchMinimumValue, searchMinimumValues, searchMismatchedValue as searchMismatch, searchMismatchedValue, searchRight, searchSubsequence, searchUnsortedValue, searchValue, searchValueAll, searchValueRight, set, set$, setPath$, shallowClone, shift, shift$, randomPermutation$ as shuffle$, length as size, slice, slice$, some, sort, sort$, splice, splice$, split, splitAt, hasPrefix as startsWith, randomSubsequence as subsequence, subsequences, randomSuffix as suffix, suffixes, swap, swap$, swapRanges, swapRanges$, symmetricDifference, tail, take, takeRight, takeWhile, takeWhileRight, reverse as toReversed, sort as toSorted, splice as toSpliced, union, union$, unique, unshift, unshift$, randomValue as value, values, set as with, zip };