Partitioned function
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
Namespace: Microsoft.Quantum.Arrays
Package: Microsoft.Quantum.Standard
Splits an array into multiple parts.
function Partitioned<'T> (nElements : Int[], arr : 'T[]) : 'T[][]
Input
nElements : Int[]
Number of elements in each part of array
arr : 'T[]
Input array to be split.
Output : 'T[][]
Multiple arrays where the first array is the first nElements[0]
of arr
and the second array are the next nElements[1]
of arr
etc. The last array
will contain all remaining elements. If the array is split exactly, the
last array will be the empty array, indicating there are no remaining elements.
In other words, Tail(Partitioned(...))
will always return the remaining
elements, while Most(Partitioned(...))
will always return the complete
partitions of the array.
Type Parameters
'T
Example
// The following returns [[1, 5], [3], [7]];
let split = Partitioned([2,1], [1,5,3,7]);
// The following returns [[1, 5], [3, 7], []];
let split = Partitioned([2,2], [1,5,3,7]);
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for