Prefixes 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

Given an array, returns all its prefixes.

function Prefixes<'T> (array : 'T[]) : 'T[][]

Description

Returns an array of all prefixes, starting with an array that only has the first element until the complete array.

Input

array : 'T[]

An array of elements.

Output : 'T[][]

Type Parameters

'T

The type of array elements.

Example

let prefixes = Prefixes([23, 42, 144]);
// prefixes = [[23], [23, 42], [23, 42, 144]]