Subarray function
Fully qualified name: Std.Arrays.Subarray
function Subarray<'T>(locations : Int[], array : 'T[]) : 'T[]
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.
If locations
contains repeated elements, the corresponding elements
of array
will likewise be repeated.
The type of array
elements.
A list of locations in the input array that is used to define the subarray.
An array from which a subarray will be generated.
An array out
of elements whose locations correspond to the subarray,
such that out[index] == array[locations[index]]
.
let array = [1, 2, 3, 4];
let permutation = Subarray([3, 0, 2, 1], array); // [4, 1, 3, 2]
let duplicates = Subarray([1, 2, 2], array); // [2, 3, 3]