Windows function
Fully qualified name: Std.Arrays.Windows
Q#
function Windows<'T>(size : Int, array : 'T[]) : 'T[][]
Returns all consecutive subarrays of length size
.
This function returns all n - size + 1
subarrays of
length size
in order, where n
is the length of array
.
The first subarrays are array[0..size - 1], array[1..size], array[2..size + 1]
until the last subarray array[n - size..n - 1]
.
The type of array
elements.
Length of the subarrays.
An array of elements.
Q#
// same as [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
let windows = Windows(3, [1, 2, 3, 4, 5]);
The size of the window must be a positive integer no greater than the size of the array