xtr.arrays¶
all¶
all(arr: Array[A], predicate: Func[(A) => Boolean]): Boolean
Returns true if all elements in arr satisfy the given predicate, otherwise false. predicate must accept an A.
Example
Resultany¶
any(arr: Array[A], function: Func[(A) => Boolean]): Boolean
Returns true if any element in arr satisfies the given predicate, otherwise false. predicate must accept an A.
Example
Resultbreak¶
break(arr: Array[A], predicate: Func[(A) => Boolean]): Object[Array[A]]
Returns an Object with two entries:
leftkey with anArray[A]containing the elements ofarrbefore the first element to satisfy the givenpredicate.rightkey with anArray[A]containing the remaining elements ofarr.
Example
ResultchunksOf¶
chunksOf(arr: Array[A], size: Number): Array[Array[A]]
Returns a new Array of Array[A], with every element containing the next size elements in arr.
Example
ResultcountBy¶
countBy(arr: Array[A], predicate: Func[(A) => Boolean]): Number
Returns a Number count of all the elements in array that satisfy the given predicate, which must accept and A.
Example
ResultdistinctBy¶
distinctBy func(value)¶
distinctBy(arr: Array[A], identity: Func[(A) => B]): Array[A]
Returns a new Array with the distinct elements in arr using the given identity function for comparison. identity must accept an A.
Example
ResultThe modulo operation on the elements yields [1, 2, 0, 1, 2, 0] meaning 1 and 4 share the same identity, therefore 1 is kept and 4 discarded. Same is true for 2 and 3 with 5 and 6, respectively.
distinctBy func(value, idx)¶
distinctBy(arr: Array[A], identity: Func[(A, Number) => B]): Array[A]
Returns a new Array with the distinct elements in arr using the given identity function for comparison. identity must accept an A.
Example
ResultThe modulo operation on the elements yields [0, 2, 3, 4, 5, 6] where all are distinct, so all elements are kept.
drop¶
drop(arr: Array[A], n: Number): Array[A]
Returns a new Array with the elements in arr but dropping the first n elements.
Example
ResultdropWhile¶
dropWhile(arr: Array[A], predicate: Func[(A) => Boolean]): Array[A]
Returns a new Array with the elements in arr, but dropping the first elements while they satisfy the given predicate, which must accept an A.
Example
ResultduplicatesBy¶
duplicatesBy(arr: Array[A]): Array[A]
Returns a new Array with the element in arr that are duplicated.
Example
Resultfind¶
find func(value)¶
find(arr: Array[A], predicate: Func[(A) => Boolean]): [A]
Returns a single element Array with the first A that satisfies the given predicate, which must accept an A.
Example
Resultfind func(value, idx)¶
find(arr: Array[A], predicate: Func[(A, Number) => Boolean]): [A]
Returns a single element Array with the first A that satisfies the given predicate, which must accept an A and its Number index.
Example
Resultflat¶
flat(arr: Array[Array[A]]): Array[Any]
Returns a new single level Array with the contents of all Array in arr, recursively flattening each Array element found.
Example
ResultindexWhere¶
indexWhere(arr: Array[A], predicate: Func[(A) => Boolean]): Number
Returns the Number index of the first element that satisfies the given predicate, otherwise -1. predicate which must accept an A.
Example
ResultindicesWhere¶
indicesWhere(arr: Array[A], predicate: Func[(A) => Boolean]): Array[Number]
Returns an Array[Number] with the indices of elements that satisfy the given predicate, which must accept an A.
Example
ResultlastIndexWhere¶
lastIndexWhere(arr: Array[A], predicate: Func[(A) => Boolean]): Number
Returns the Number index of the last element in arr that satisfies the given predicate, otherwise -1. predicate which must accept an A.
Example
ResultoccurrencesBy¶
occurrencesBy(arr: Array[A], identity: Func[(A) => String]): Object[Number]
Returns an Object with an entry for each unique identity of elements in arr. The value of each entry is the Number of elements in arr that produced such identity, using identity. identity must take an A.
Example
Resultpartition¶
partition(arr: Array[A], predicate: Func[(A) => Boolean]): Object[A]
Returns an Object with two entries:
passkey with anArray[A]of the subset of elements inarrthat satisfy the givenpredicate, which must take anA.failkey with anArray[A]of the subset of elements inarrthat fail the givenpredicate, which must take anA.
Example
ResultsplitAt¶
splitAt(arr: Array[A], n: Number): Object[A]
Returns an Object[A] with two entries:
leftkey with anArray[A]containing the elements ofarrbefore thenelement.rightkey with anArray[A]containing the remaining elements ofarr.
Example
Resulttake¶
take(arr: Array[A], n: Number): Array[A]
Returns a new Array with the elements in arry, but only taking the first n elements.
Example
ResulttakeWhile¶
takeWhile(arr: Array[A], predicate: Func[(A) => Boolean]): Array[A]
Returns a new Array with the elements in arr, but only taking the first elements that satisfy the given predicate, which must accept an A.
Example
Resultunzip¶
unzip(arr: Array[Array[A]]): Array[Array[A]]
Create n-number of Arrays, each containing the n-th element of every array in arr.
Returns a new Array of equal size to the shortest array in arr. Every n-th element in the result is an Array containing the n-th element the arrays in arr.
Example
Resultzip¶
zip(arr1: Array[A], arr2: Array[B], arrN: Array[C]*): Array[Array[A|B|C]]
Combines corresponding elements of the given arrays.
Returns a new Array of equal size to the shortest array given. Every n-th element in the result is an Array containing the n-th element of the given arrays.
Example
Result