Std.Arrays

The Std.Arrays namespace contains the following functions and operations:

Name Description
All Given an array and a predicate that is defined for the elements of the array, and checks if all elements of the array satisfy the predicate.
Any Given an array and a predicate that is defined for the elements of the array, checks if at least one element of the array satisfies the predicate.
Chunks Splits an array into multiple parts of equal length.
CircularlyShifted Shift an array circularly left or right by a specific step size.
ColumnAt Extracts a column from a matrix.
Count Given an array and a predicate that is defined for the elements of the array, returns the number of elements an array that consists of those elements that satisfy the predicate.
Diagonal Returns an array of diagonal elements of a 2-dimensional array
DrawMany Repeats an operation for a given number of samples, collecting its outputs in an array.
Enumerated Given an array, returns a new array containing elements of the original array along with the indices of each element.
Excluding Returns an array containing the elements of another array, excluding elements at a given list of indices.
Filtered Given an array and a predicate that is defined for the elements of the array, returns an array that consists of those elements that satisfy the predicate.
FlatMapped Given an array and a function that maps an array element to some output array, returns the concatenated output arrays for each array element.
Flattened Given an array of arrays, returns the concatenation of all arrays.
Fold Iterates a function f through an array array, returning f(...f(f(initialState, array[0]), array[1]), ...).
ForEach Given an array and an operation that is defined for the elements of the array, returns a new array that consists of the images of the original array under the operation.
Head Returns the first element of the array.
HeadAndRest Returns a tuple of first and all remaining elements of the array.
IndexOf Returns the first index of the first element in an array that satisfies a given predicate. If no such element exists, returns -1.
IndexRange Given an array, returns a range over the indices of that array, suitable for use in a for loop.
Interleaved Interleaves two arrays of (almost) same size.
IsEmpty Returns true if and only if an array is empty.
IsRectangularArray Returns whether a 2-dimensional array has a rectangular shape
IsSorted Given an array, returns whether that array is sorted as defined by a given comparison function.
IsSquareArray Returns whether a 2-dimensional array has a square shape
Mapped Given an array and a function that is defined for the elements of the array, returns a new array that consists of the images of the original array under the function.
MappedByIndex Given an array and a function that is defined for the indexed elements of the array, returns a new array that consists of the images of the original array under the function.
MappedOverRange Given a range and a function that takes an integer as input, returns a new array that consists of the images of the range values under the function.
Most Creates an array that is equal to an input array except that the last array element is dropped.
MostAndTail Returns a tuple of all but one and the last element of the array.
Padded Returns an array padded at with specified values up to a specified length.
Partitioned Splits an array into multiple parts.
Rest Creates an array that is equal to an input array except that the first array element is dropped.
Reversed Create an array that contains the same elements as an input array but in reversed order.
SequenceI Get an array of integers in a given interval.
SequenceL Get an array of integers in a given interval.
Sorted Given an array, returns the elements of that array sorted by a given comparison function.
Subarray Takes an array and a list of locations and produces a new array formed from the elements of the original array that match the given locations.
Swapped Applies a swap of two elements in an array.
Tail Returns the last element of the array.
Transposed Returns the transpose of a matrix represented as an array of arrays.
Unzipped Given an array of 2-tuples, returns a tuple of two arrays, each containing the elements of the tuples of the input array.
Where Given a predicate and an array, returns the indices of that array where the predicate is true.
Windows Returns all consecutive subarrays of length size.
Zipped Given two arrays, returns a new array of pairs such that each pair contains an element from each original array.