Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 1.13 KB

microsoft.quantum.arrays.prefixes.md

File metadata and controls

59 lines (36 loc) · 1.13 KB
uid title ms.date ms.topic qsharp.kind qsharp.namespace qsharp.name qsharp.summary
Microsoft.Quantum.Arrays.Prefixes
Prefixes function
7/28/2023 12:00:00 AM
managed-reference
function
Microsoft.Quantum.Arrays
Prefixes
Given an array, returns all its prefixes.

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]]