qsharp-lang 1.1.2-dev → 1.1.4-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/katas-content.generated.js +133 -122
- package/dist/language-service/language-service.d.ts +3 -1
- package/dist/language-service/language-service.js +3 -0
- package/dist/language-service/worker-proxy.js +1 -0
- package/docs/Microsoft.Quantum.Arrays/All.md +44 -0
- package/docs/Microsoft.Quantum.Arrays/Any.md +43 -0
- package/docs/Microsoft.Quantum.Arrays/Chunks.md +34 -0
- package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +46 -0
- package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +47 -0
- package/docs/Microsoft.Quantum.Arrays/Count.md +44 -0
- package/docs/Microsoft.Quantum.Arrays/Diagonal.md +43 -0
- package/docs/Microsoft.Quantum.Arrays/DrawMany.md +44 -0
- package/docs/Microsoft.Quantum.Arrays/Enumerated.md +45 -0
- package/docs/Microsoft.Quantum.Arrays/Excluding.md +47 -0
- package/docs/Microsoft.Quantum.Arrays/Filtered.md +44 -0
- package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +46 -0
- package/docs/Microsoft.Quantum.Arrays/Flattened.md +38 -0
- package/docs/Microsoft.Quantum.Arrays/Fold.md +47 -0
- package/docs/Microsoft.Quantum.Arrays/ForEach.md +43 -0
- package/docs/Microsoft.Quantum.Arrays/Head.md +32 -0
- package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +32 -0
- package/docs/Microsoft.Quantum.Arrays/IndexOf.md +40 -0
- package/docs/Microsoft.Quantum.Arrays/IndexRange.md +41 -0
- package/docs/Microsoft.Quantum.Arrays/Interleaved.md +49 -0
- package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +28 -0
- package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +42 -0
- package/docs/Microsoft.Quantum.Arrays/IsSorted.md +43 -0
- package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +42 -0
- package/docs/Microsoft.Quantum.Arrays/Mapped.md +43 -0
- package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +54 -0
- package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +48 -0
- package/docs/Microsoft.Quantum.Arrays/Most.md +34 -0
- package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +32 -0
- package/docs/Microsoft.Quantum.Arrays/Padded.md +50 -0
- package/docs/Microsoft.Quantum.Arrays/Partitioned.md +44 -0
- package/docs/Microsoft.Quantum.Arrays/Rest.md +34 -0
- package/docs/Microsoft.Quantum.Arrays/Reversed.md +34 -0
- package/docs/Microsoft.Quantum.Arrays/SequenceI.md +41 -0
- package/docs/Microsoft.Quantum.Arrays/SequenceL.md +41 -0
- package/docs/Microsoft.Quantum.Arrays/Sorted.md +52 -0
- package/docs/Microsoft.Quantum.Arrays/Subarray.md +51 -0
- package/docs/Microsoft.Quantum.Arrays/Swapped.md +40 -0
- package/docs/Microsoft.Quantum.Arrays/Tail.md +32 -0
- package/docs/Microsoft.Quantum.Arrays/Transposed.md +47 -0
- package/docs/Microsoft.Quantum.Arrays/Unzipped.md +46 -0
- package/docs/Microsoft.Quantum.Arrays/Where.md +36 -0
- package/docs/Microsoft.Quantum.Arrays/Windows.md +47 -0
- package/docs/Microsoft.Quantum.Arrays/Zipped.md +50 -0
- package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +35 -0
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +42 -0
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +41 -0
- package/docs/Microsoft.Quantum.Canon/ApplyP.md +39 -0
- package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +41 -0
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +47 -0
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +45 -0
- package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +34 -0
- package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +38 -0
- package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +43 -0
- package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +43 -0
- package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +43 -0
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +31 -0
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +31 -0
- package/docs/Microsoft.Quantum.Canon/CX.md +50 -0
- package/docs/Microsoft.Quantum.Canon/CY.md +44 -0
- package/docs/Microsoft.Quantum.Canon/CZ.md +44 -0
- package/docs/Microsoft.Quantum.Canon/Fst.md +20 -0
- package/docs/Microsoft.Quantum.Canon/Snd.md +20 -0
- package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +25 -0
- package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +36 -0
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +35 -0
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +25 -0
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +30 -0
- package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +30 -0
- package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +30 -0
- package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +30 -0
- package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +21 -0
- package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +36 -0
- package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +21 -0
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +30 -0
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +34 -0
- package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +30 -0
- package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +32 -0
- package/docs/Microsoft.Quantum.Core/Length.md +28 -0
- package/docs/Microsoft.Quantum.Core/RangeEnd.md +38 -0
- package/docs/Microsoft.Quantum.Core/RangeReverse.md +32 -0
- package/docs/Microsoft.Quantum.Core/RangeStart.md +36 -0
- package/docs/Microsoft.Quantum.Core/RangeStep.md +33 -0
- package/docs/Microsoft.Quantum.Core/Repeated.md +36 -0
- package/docs/Microsoft.Quantum.Diagnostics/CheckAllZero.md +18 -0
- package/docs/Microsoft.Quantum.Diagnostics/CheckOperationsAreEqual.md +47 -0
- package/docs/Microsoft.Quantum.Diagnostics/CheckZero.md +18 -0
- package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +18 -0
- package/docs/Microsoft.Quantum.Diagnostics/Fact.md +20 -0
- package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +35 -0
- package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +47 -0
- package/docs/Microsoft.Quantum.Intrinsic/Exp.md +40 -0
- package/docs/Microsoft.Quantum.Intrinsic/H.md +34 -0
- package/docs/Microsoft.Quantum.Intrinsic/I.md +25 -0
- package/docs/Microsoft.Quantum.Intrinsic/M.md +46 -0
- package/docs/Microsoft.Quantum.Intrinsic/Measure.md +56 -0
- package/docs/Microsoft.Quantum.Intrinsic/Message.md +30 -0
- package/docs/Microsoft.Quantum.Intrinsic/R.md +42 -0
- package/docs/Microsoft.Quantum.Intrinsic/R1.md +41 -0
- package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +57 -0
- package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +58 -0
- package/docs/Microsoft.Quantum.Intrinsic/Reset.md +27 -0
- package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +27 -0
- package/docs/Microsoft.Quantum.Intrinsic/Rx.md +44 -0
- package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +42 -0
- package/docs/Microsoft.Quantum.Intrinsic/Ry.md +44 -0
- package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +42 -0
- package/docs/Microsoft.Quantum.Intrinsic/Rz.md +44 -0
- package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +42 -0
- package/docs/Microsoft.Quantum.Intrinsic/S.md +36 -0
- package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +49 -0
- package/docs/Microsoft.Quantum.Intrinsic/T.md +36 -0
- package/docs/Microsoft.Quantum.Intrinsic/X.md +36 -0
- package/docs/Microsoft.Quantum.Intrinsic/Y.md +36 -0
- package/docs/Microsoft.Quantum.Intrinsic/Z.md +36 -0
- package/docs/Microsoft.Quantum.Logical/Xor.md +38 -0
- package/docs/Microsoft.Quantum.Math/AbsComplex.md +30 -0
- package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +30 -0
- package/docs/Microsoft.Quantum.Math/AbsD.md +21 -0
- package/docs/Microsoft.Quantum.Math/AbsI.md +21 -0
- package/docs/Microsoft.Quantum.Math/AbsL.md +20 -0
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +30 -0
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +30 -0
- package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +40 -0
- package/docs/Microsoft.Quantum.Math/ArcCos.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcCosh.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcSin.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcSinh.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcTan.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcTan2.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArcTanh.md +21 -0
- package/docs/Microsoft.Quantum.Math/ArgComplex.md +30 -0
- package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +28 -0
- package/docs/Microsoft.Quantum.Math/Binom.md +34 -0
- package/docs/Microsoft.Quantum.Math/BitSizeI.md +23 -0
- package/docs/Microsoft.Quantum.Math/BitSizeL.md +23 -0
- package/docs/Microsoft.Quantum.Math/Ceiling.md +23 -0
- package/docs/Microsoft.Quantum.Math/Complex.md +31 -0
- package/docs/Microsoft.Quantum.Math/ComplexPolar.md +29 -0
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +25 -0
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +25 -0
- package/docs/Microsoft.Quantum.Math/Cos.md +21 -0
- package/docs/Microsoft.Quantum.Math/Cosh.md +21 -0
- package/docs/Microsoft.Quantum.Math/DivRemI.md +21 -0
- package/docs/Microsoft.Quantum.Math/DivRemL.md +21 -0
- package/docs/Microsoft.Quantum.Math/DividedByC.md +30 -0
- package/docs/Microsoft.Quantum.Math/DividedByCP.md +30 -0
- package/docs/Microsoft.Quantum.Math/E.md +28 -0
- package/docs/Microsoft.Quantum.Math/ExpModI.md +23 -0
- package/docs/Microsoft.Quantum.Math/ExpModL.md +23 -0
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +23 -0
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +23 -0
- package/docs/Microsoft.Quantum.Math/FactorialI.md +38 -0
- package/docs/Microsoft.Quantum.Math/FactorialL.md +32 -0
- package/docs/Microsoft.Quantum.Math/Floor.md +23 -0
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +23 -0
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +23 -0
- package/docs/Microsoft.Quantum.Math/HammingWeightI.md +21 -0
- package/docs/Microsoft.Quantum.Math/InverseModI.md +25 -0
- package/docs/Microsoft.Quantum.Math/InverseModL.md +25 -0
- package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +34 -0
- package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +34 -0
- package/docs/Microsoft.Quantum.Math/IsInfinite.md +49 -0
- package/docs/Microsoft.Quantum.Math/IsNaN.md +30 -0
- package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +31 -0
- package/docs/Microsoft.Quantum.Math/Lg.md +21 -0
- package/docs/Microsoft.Quantum.Math/Log.md +21 -0
- package/docs/Microsoft.Quantum.Math/Log10.md +21 -0
- package/docs/Microsoft.Quantum.Math/LogFactorialD.md +35 -0
- package/docs/Microsoft.Quantum.Math/LogGammaD.md +39 -0
- package/docs/Microsoft.Quantum.Math/LogOf2.md +24 -0
- package/docs/Microsoft.Quantum.Math/Max.md +28 -0
- package/docs/Microsoft.Quantum.Math/MaxD.md +21 -0
- package/docs/Microsoft.Quantum.Math/MaxI.md +21 -0
- package/docs/Microsoft.Quantum.Math/MaxL.md +21 -0
- package/docs/Microsoft.Quantum.Math/Min.md +28 -0
- package/docs/Microsoft.Quantum.Math/MinD.md +21 -0
- package/docs/Microsoft.Quantum.Math/MinI.md +21 -0
- package/docs/Microsoft.Quantum.Math/MinL.md +21 -0
- package/docs/Microsoft.Quantum.Math/MinusC.md +30 -0
- package/docs/Microsoft.Quantum.Math/MinusCP.md +30 -0
- package/docs/Microsoft.Quantum.Math/ModulusI.md +23 -0
- package/docs/Microsoft.Quantum.Math/ModulusL.md +23 -0
- package/docs/Microsoft.Quantum.Math/NegationC.md +28 -0
- package/docs/Microsoft.Quantum.Math/NegationCP.md +28 -0
- package/docs/Microsoft.Quantum.Math/PI.md +28 -0
- package/docs/Microsoft.Quantum.Math/PNorm.md +34 -0
- package/docs/Microsoft.Quantum.Math/PNormalized.md +39 -0
- package/docs/Microsoft.Quantum.Math/PlusC.md +30 -0
- package/docs/Microsoft.Quantum.Math/PlusCP.md +30 -0
- package/docs/Microsoft.Quantum.Math/PowC.md +32 -0
- package/docs/Microsoft.Quantum.Math/PowCP.md +32 -0
- package/docs/Microsoft.Quantum.Math/RealMod.md +38 -0
- package/docs/Microsoft.Quantum.Math/Round.md +23 -0
- package/docs/Microsoft.Quantum.Math/SignD.md +21 -0
- package/docs/Microsoft.Quantum.Math/SignI.md +21 -0
- package/docs/Microsoft.Quantum.Math/SignL.md +21 -0
- package/docs/Microsoft.Quantum.Math/Sin.md +21 -0
- package/docs/Microsoft.Quantum.Math/Sinh.md +21 -0
- package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +30 -0
- package/docs/Microsoft.Quantum.Math/Sqrt.md +21 -0
- package/docs/Microsoft.Quantum.Math/SquaredNorm.md +32 -0
- package/docs/Microsoft.Quantum.Math/Tan.md +21 -0
- package/docs/Microsoft.Quantum.Math/Tanh.md +21 -0
- package/docs/Microsoft.Quantum.Math/TimesC.md +30 -0
- package/docs/Microsoft.Quantum.Math/TimesCP.md +30 -0
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +23 -0
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +23 -0
- package/docs/Microsoft.Quantum.Math/Truncate.md +23 -0
- package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +28 -0
- package/docs/Microsoft.Quantum.Measurement/MResetX.md +37 -0
- package/docs/Microsoft.Quantum.Measurement/MResetY.md +37 -0
- package/docs/Microsoft.Quantum.Measurement/MResetZ.md +37 -0
- package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +36 -0
- package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +30 -0
- package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +36 -0
- package/docs/Microsoft.Quantum.Random/DrawRandomDouble.md +40 -0
- package/docs/Microsoft.Quantum.Random/DrawRandomInt.md +40 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +35 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +39 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +36 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +25 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +22 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +25 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +32 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +23 -0
- package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +29 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +25 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +25 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +25 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +25 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +23 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +25 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +32 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +27 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +27 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +27 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +27 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +36 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +27 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +36 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +34 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +37 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +34 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +34 -0
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +35 -0
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +68 -0
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +65 -0
- package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +53 -0
- package/docs/toc.yml +305 -0
- package/lib/node/qsc_wasm.cjs +40 -13
- package/lib/node/qsc_wasm.d.cts +15 -0
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.d.ts +17 -0
- package/lib/web/qsc_wasm.js +38 -11
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +4 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.ForEach
|
|
3
|
+
title: ForEach operation
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: opeartion
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: ForEach
|
|
9
|
+
qsharp.summary: Given an array and an operation that is defined
|
|
10
|
+
for the elements of the array, returns a new array that consists
|
|
11
|
+
of the images of the original array under the operation.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# ForEach operation
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
operation ForEach<'T, 'U>(action : ('T => 'U), array : 'T[]) : 'U[]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and an operation that is defined
|
|
24
|
+
for the elements of the array, returns a new array that consists
|
|
25
|
+
of the images of the original array under the operation.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
### 'U
|
|
31
|
+
The result type of the `action` operation.
|
|
32
|
+
|
|
33
|
+
## Input
|
|
34
|
+
### action
|
|
35
|
+
An operation from `'T` to `'U` that is applied to each element.
|
|
36
|
+
### array
|
|
37
|
+
An array of elements over `'T`.
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
An array `'U[]` of elements that are mapped by the `action` operation.
|
|
41
|
+
|
|
42
|
+
## See Also
|
|
43
|
+
- Microsoft.Quantum.Arrays.Mapped
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Head
|
|
3
|
+
title: Head function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: Head
|
|
9
|
+
qsharp.summary: Returns the first element of the array.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Head function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function Head<'A>(array : 'A[]) : 'A
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns the first element of the array.
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'A
|
|
25
|
+
The type of the array elements.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### array
|
|
29
|
+
Array of which the first element is taken. Array must have at least 1 element.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
The first element of the array.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.HeadAndRest
|
|
3
|
+
title: HeadAndRest function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: HeadAndRest
|
|
9
|
+
qsharp.summary: Returns a tuple of first and all remaining elements of the array.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# HeadAndRest function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function HeadAndRest<'A>(array : 'A[]) : ('A, 'A[])
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns a tuple of first and all remaining elements of the array.
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'A
|
|
25
|
+
The type of the array elements.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### array
|
|
29
|
+
An array with at least one element.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
A tuple of first and all remaining elements of the array.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IndexOf
|
|
3
|
+
title: IndexOf function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IndexOf
|
|
9
|
+
qsharp.summary: Returns the first index of the first element in an array that satisfies
|
|
10
|
+
a given predicate. If no such element exists, returns -1.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# IndexOf function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function IndexOf<'T>(predicate : ('T -> Bool), array : 'T[]) : Int
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Returns the first index of the first element in an array that satisfies
|
|
23
|
+
a given predicate. If no such element exists, returns -1.
|
|
24
|
+
|
|
25
|
+
## Input
|
|
26
|
+
### predicate
|
|
27
|
+
A predicate function acting on elements of the array.
|
|
28
|
+
### array
|
|
29
|
+
An array to be searched using the given predicate.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
Either the smallest index of an element for which `predicate(array[index])` is true,
|
|
33
|
+
or -1 if no such element exists.
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
The following code gets the index of the first even number in the input array.
|
|
37
|
+
```qsharp
|
|
38
|
+
let indexOfFirstEven = IndexOf(x -> x % 2 == 0, [1, 3, 17, 2, 21]);
|
|
39
|
+
// `indexOfFirstEven` is 3.
|
|
40
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IndexRange
|
|
3
|
+
title: IndexRange function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IndexRange
|
|
9
|
+
qsharp.summary: Given an array, returns a range over the indices of that array, suitable
|
|
10
|
+
for use in a for loop.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# IndexRange function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function IndexRange<'TElement>(array : 'TElement[]) : Range
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Given an array, returns a range over the indices of that array, suitable
|
|
23
|
+
for use in a for loop.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'TElement
|
|
27
|
+
The type of elements of the array.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### array
|
|
31
|
+
An array for which a range of indices should be returned.
|
|
32
|
+
|
|
33
|
+
## Output
|
|
34
|
+
A range over all indices of the array.
|
|
35
|
+
|
|
36
|
+
## Example
|
|
37
|
+
The following `for` loops are equivalent:
|
|
38
|
+
```qsharp
|
|
39
|
+
for idx in IndexRange(array) { ... }
|
|
40
|
+
for idx in 0 .. Length(array) - 1 { ... }
|
|
41
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Interleaved
|
|
3
|
+
title: Interleaved function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: Interleaved
|
|
9
|
+
qsharp.summary: Interleaves two arrays of (almost) same size.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Interleaved function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function Interleaved<'T>(first : 'T[], second : 'T[]) : 'T[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Interleaves two arrays of (almost) same size.
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
This function returns the interleaving of two arrays, starting
|
|
25
|
+
with the first element from the first array, then the first
|
|
26
|
+
element from the second array, and so on.
|
|
27
|
+
|
|
28
|
+
The first array must either be
|
|
29
|
+
of the same length as the second one, or can have one more element.
|
|
30
|
+
|
|
31
|
+
## Type Parameters
|
|
32
|
+
### 'T
|
|
33
|
+
The type of each element of `first` and `second`.
|
|
34
|
+
|
|
35
|
+
## Input
|
|
36
|
+
### first
|
|
37
|
+
The first array to be interleaved.
|
|
38
|
+
|
|
39
|
+
### second
|
|
40
|
+
The second array to be interleaved.
|
|
41
|
+
|
|
42
|
+
## Output
|
|
43
|
+
Interleaved array
|
|
44
|
+
|
|
45
|
+
## Example
|
|
46
|
+
```qsharp
|
|
47
|
+
// same as interleaved = [1, -1, 2, -2, 3, -3]
|
|
48
|
+
let interleaved = Interleaved([1, 2, 3], [-1, -2, -3])
|
|
49
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IsEmpty
|
|
3
|
+
title: IsEmpty function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IsEmpty
|
|
9
|
+
qsharp.summary: Returns true if and only if an array is empty.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# IsEmpty function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function IsEmpty<'T>(array : 'T[]) : Bool
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns true if and only if an array is empty.
|
|
22
|
+
|
|
23
|
+
## Input
|
|
24
|
+
### array
|
|
25
|
+
The array to be checked.
|
|
26
|
+
|
|
27
|
+
## Output
|
|
28
|
+
`true` if and only if the array is empty (has length 0).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IsRectangularArray
|
|
3
|
+
title: IsRectangularArray function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IsRectangularArray
|
|
9
|
+
qsharp.summary: Returns whether a 2-dimensional array has a rectangular shape
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# IsRectangularArray function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function IsRectangularArray<'T>(array : 'T[][]) : Bool
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns whether a 2-dimensional array has a rectangular shape
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'T
|
|
25
|
+
The type of each element of `array`.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### array
|
|
29
|
+
A 2-dimensional array of elements.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
`true` if the array is rectangular, `false` otherwise.
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
```qsharp
|
|
36
|
+
IsRectangularArray([[1, 2], [3, 4]]); // true
|
|
37
|
+
IsRectangularArray([[1, 2, 3], [4, 5, 6]]); // true
|
|
38
|
+
IsRectangularArray([[1, 2], [3, 4, 5]]); // false
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## See Also
|
|
42
|
+
- Microsoft.Quantum.Arrays.IsSquareArray
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IsSorted
|
|
3
|
+
title: IsSorted function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IsSorted
|
|
9
|
+
qsharp.summary: Given an array, returns whether that array is sorted as defined by
|
|
10
|
+
a given comparison function.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# IsSorted function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function IsSorted<'T>(comparison : (('T, 'T) -> Bool), array : 'T[]) : Bool
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Given an array, returns whether that array is sorted as defined by
|
|
23
|
+
a given comparison function.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'T
|
|
27
|
+
The type of each element of `array`.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### comparison
|
|
31
|
+
A function that compares two elements such that `a` is considered to
|
|
32
|
+
be less than or equal to `b` if `comparison(a, b)` is `true`.
|
|
33
|
+
### array
|
|
34
|
+
The array to be checked.
|
|
35
|
+
|
|
36
|
+
## Output
|
|
37
|
+
`true` if and only if for each pair of elements `a` and `b` of
|
|
38
|
+
`array` occurring in that order, `comparison(a, b)` is `true`.
|
|
39
|
+
|
|
40
|
+
## Remarks
|
|
41
|
+
The function `comparison` is assumed to be transitive, such that
|
|
42
|
+
if `comparison(a, b)` and `comparison(b, c)`, then `comparison(a, c)`
|
|
43
|
+
is assumed.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.IsSquareArray
|
|
3
|
+
title: IsSquareArray function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: IsSquareArray
|
|
9
|
+
qsharp.summary: Returns whether a 2-dimensional array has a square shape
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# IsSquareArray function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function IsSquareArray<'T>(array : 'T[][]) : Bool
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns whether a 2-dimensional array has a square shape
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'T
|
|
25
|
+
The type of each element of `array`.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### array
|
|
29
|
+
A 2-dimensional array of elements.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
```qsharp
|
|
33
|
+
IsSquareArray([[1, 2], [3, 4]]); // true
|
|
34
|
+
IsSquareArray([[1, 2, 3], [4, 5, 6]]); // false
|
|
35
|
+
IsSquareArray([[1, 2], [3, 4], [5, 6]]); // false
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Output
|
|
39
|
+
`true` if the array is square, `false` otherwise.
|
|
40
|
+
|
|
41
|
+
## See Also
|
|
42
|
+
- Microsoft.Quantum.Arrays.IsRectangularArray
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Mapped
|
|
3
|
+
title: Mapped function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: Mapped
|
|
9
|
+
qsharp.summary: Given an array and a function that is defined
|
|
10
|
+
for the elements of the array, returns a new array that consists
|
|
11
|
+
of the images of the original array under the function.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Mapped function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function Mapped<'T, 'U>(mapper : ('T -> 'U), array : 'T[]) : 'U[]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a function that is defined
|
|
24
|
+
for the elements of the array, returns a new array that consists
|
|
25
|
+
of the images of the original array under the function.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
### 'U
|
|
31
|
+
The result type of the `mapper` function.
|
|
32
|
+
|
|
33
|
+
## Input
|
|
34
|
+
### mapper
|
|
35
|
+
A function from `'T` to `'U` that is used to map elements.
|
|
36
|
+
### array
|
|
37
|
+
An array of elements over `'T`.
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
An array `'U[]` of elements that are mapped by the `mapper` function.
|
|
41
|
+
|
|
42
|
+
## See Also
|
|
43
|
+
- Microsoft.Quantum.Arrays.ForEach
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.MappedByIndex
|
|
3
|
+
title: MappedByIndex function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: MappedByIndex
|
|
9
|
+
qsharp.summary: Given an array and a function that is defined
|
|
10
|
+
for the indexed elements of the array, returns a new array that consists
|
|
11
|
+
of the images of the original array under the function.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# MappedByIndex function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function MappedByIndex<'T, 'U>(mapper : ((Int, 'T) -> 'U), array : 'T[]) : 'U[]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a function that is defined
|
|
24
|
+
for the indexed elements of the array, returns a new array that consists
|
|
25
|
+
of the images of the original array under the function.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
### 'U
|
|
31
|
+
The result type of the `mapper` function.
|
|
32
|
+
|
|
33
|
+
## Input
|
|
34
|
+
### mapper
|
|
35
|
+
A function from `(Int, 'T)` to `'U` that is used to map elements
|
|
36
|
+
and their indices.
|
|
37
|
+
### array
|
|
38
|
+
An array of elements over `'T`.
|
|
39
|
+
|
|
40
|
+
## Output
|
|
41
|
+
An array `'U[]` of elements that are mapped by the `mapper` function.
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
The following two lines are equivalent:
|
|
45
|
+
```qsharp
|
|
46
|
+
let array = MappedByIndex(f, [x0, x1, x2]);
|
|
47
|
+
```
|
|
48
|
+
and
|
|
49
|
+
```qsharp
|
|
50
|
+
let array = [f(0, x0), f(1, x1), f(2, x2)];
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## See Also
|
|
54
|
+
- Microsoft.Quantum.Arrays.Mapped
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.MappedOverRange
|
|
3
|
+
title: MappedOverRange function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: MappedOverRange
|
|
9
|
+
qsharp.summary: Given a range and a function that takes an integer as input,
|
|
10
|
+
returns a new array that consists
|
|
11
|
+
of the images of the range values under the function.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# MappedOverRange function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function MappedOverRange<'T>(mapper : (Int -> 'T), range : Range) : 'T[]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given a range and a function that takes an integer as input,
|
|
24
|
+
returns a new array that consists
|
|
25
|
+
of the images of the range values under the function.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The result type of the `mapper` function.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### mapper
|
|
33
|
+
A function from `Int` to `'T` that is used to map range values.
|
|
34
|
+
### range
|
|
35
|
+
A range of integers.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
An array `'T[]` of elements that are mapped by the `mapper` function.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
This example adds 1 to a range of even numbers:
|
|
42
|
+
```qsharp
|
|
43
|
+
let numbers = MappedOverRange(x -> x + 1, 0..2..10);
|
|
44
|
+
// numbers = [1, 3, 5, 7, 9, 11]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## See Also
|
|
48
|
+
- Microsoft.Quantum.Arrays.Mapped
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Most
|
|
3
|
+
title: Most function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: Most
|
|
9
|
+
qsharp.summary: Creates an array that is equal to an input array except that the last array
|
|
10
|
+
element is dropped.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Most function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function Most<'T>(array : 'T[]) : 'T[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Creates an array that is equal to an input array except that the last array
|
|
23
|
+
element is dropped.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'T
|
|
27
|
+
The type of the array elements.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### array
|
|
31
|
+
An array whose first to second-to-last elements are to form the output array.
|
|
32
|
+
|
|
33
|
+
## Output
|
|
34
|
+
An array containing the elements `array[0..Length(array) - 2]`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.MostAndTail
|
|
3
|
+
title: MostAndTail function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: MostAndTail
|
|
9
|
+
qsharp.summary: Returns a tuple of all but one and the last element of the array.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# MostAndTail function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function MostAndTail<'A>(array : 'A[]) : ('A[], 'A)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns a tuple of all but one and the last element of the array.
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'A
|
|
25
|
+
The type of the array elements.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### array
|
|
29
|
+
An array with at least one element.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
A tuple of all but one and the last element of the array.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Padded
|
|
3
|
+
title: Padded function
|
|
4
|
+
ms.date: 02/16/2024 12:00:00 AM
|
|
5
|
+
ms.topic: managed-reference
|
|
6
|
+
qsharp.kind: function
|
|
7
|
+
qsharp.namespace: Microsoft.Quantum.Arrays
|
|
8
|
+
qsharp.name: Padded
|
|
9
|
+
qsharp.summary: Returns an array padded at with specified values up to a
|
|
10
|
+
specified length.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Padded function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function Padded<'T>(paddedLength : Int, defaultElement : 'T, inputArray : 'T[]) : 'T[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Returns an array padded at with specified values up to a
|
|
23
|
+
specified length.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'T
|
|
27
|
+
The type of the array elements.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### paddedLength
|
|
31
|
+
The length of the padded array. If this is positive, `array`
|
|
32
|
+
is padded at the head. If this is negative, `array` is padded
|
|
33
|
+
at the tail.
|
|
34
|
+
### defaultElement
|
|
35
|
+
Default value to use for padding elements.
|
|
36
|
+
### array
|
|
37
|
+
Array to be padded.
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
An array `output` that is the `array` padded at the head or the tail
|
|
41
|
+
with `defaultElement`s until `output` has length `paddedLength`
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
```qsharp
|
|
45
|
+
let array = [10, 11, 12];
|
|
46
|
+
// The following line returns [10, 12, 15, 2, 2].
|
|
47
|
+
let output = Padded(-5, 2, array);
|
|
48
|
+
// The following line returns [2, 2, 10, 12, 15].
|
|
49
|
+
let output = Padded(5, 2, array);
|
|
50
|
+
```
|