Padded 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
Returns an array padded at with specified values up to a specified length.
function Padded<'T> (nElementsTotal : Int, defaultElement : 'T, inputArray : 'T[]) : 'T[]
Input
nElementsTotal : Int
The length of the padded array. If this is positive, inputArray
is padded at the head. If this is negative, inputArray
is padded
at the tail.
defaultElement : 'T
Default value to use for padding elements.
inputArray : 'T[]
Array whose values are at the head of the output array.
Output : 'T[]
An array output
that is the inputArray
padded at the head
with defaultElement
s until output
has length nElementsTotal
Type Parameters
'T
The type of the array elements.
Example
let array = [10, 11, 12];
// The following line returns [10, 12, 15, 2, 2, 2].
let output = Padded(-6, 2, array);
// The following line returns [2, 2, 2, 10, 12, 15].
let output = Padded(6, 2, array);
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