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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICompletionList, IHover, ILocation,
|
|
1
|
+
import type { ICodeLens, ICompletionList, IHover, ILocation, INotebookMetadata, IPosition, ISignatureHelp, ITextEdit, IWorkspaceConfiguration, IWorkspaceEdit, VSDiagnostic } from "../../lib/node/qsc_wasm.cjs";
|
|
2
2
|
import { IServiceProxy } from "../worker-proxy.js";
|
|
3
3
|
type QscWasm = typeof import("../../lib/node/qsc_wasm.cjs");
|
|
4
4
|
export type LanguageServiceEvent = {
|
|
@@ -26,6 +26,7 @@ export interface ILanguageService {
|
|
|
26
26
|
getSignatureHelp(documentUri: string, position: IPosition): Promise<ISignatureHelp | undefined>;
|
|
27
27
|
getRename(documentUri: string, position: IPosition, newName: string): Promise<IWorkspaceEdit | undefined>;
|
|
28
28
|
prepareRename(documentUri: string, position: IPosition): Promise<ITextEdit | undefined>;
|
|
29
|
+
getCodeLenses(documentUri: string): Promise<ICodeLens[]>;
|
|
29
30
|
dispose(): Promise<void>;
|
|
30
31
|
addEventListener<T extends LanguageServiceEvent["type"]>(type: T, listener: (event: Extract<LanguageServiceEvent, {
|
|
31
32
|
type: T;
|
|
@@ -60,6 +61,7 @@ export declare class QSharpLanguageService implements ILanguageService {
|
|
|
60
61
|
getSignatureHelp(documentUri: string, position: IPosition): Promise<ISignatureHelp | undefined>;
|
|
61
62
|
getRename(documentUri: string, position: IPosition, newName: string): Promise<IWorkspaceEdit | undefined>;
|
|
62
63
|
prepareRename(documentUri: string, position: IPosition): Promise<ITextEdit | undefined>;
|
|
64
|
+
getCodeLenses(documentUri: string): Promise<ICodeLens[]>;
|
|
63
65
|
dispose(): Promise<void>;
|
|
64
66
|
addEventListener<T extends LanguageServiceEvent["type"]>(type: T, listener: (event: Extract<LanguageServiceEvent, {
|
|
65
67
|
type: T;
|
|
@@ -46,6 +46,9 @@ export class QSharpLanguageService {
|
|
|
46
46
|
async prepareRename(documentUri, position) {
|
|
47
47
|
return this.languageService.prepare_rename(documentUri, position);
|
|
48
48
|
}
|
|
49
|
+
async getCodeLenses(documentUri) {
|
|
50
|
+
return this.languageService.get_code_lenses(documentUri);
|
|
51
|
+
}
|
|
49
52
|
async dispose() {
|
|
50
53
|
this.languageService.stop_background_work();
|
|
51
54
|
await this.backgroundWork;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.All
|
|
3
|
+
title: All 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: All
|
|
9
|
+
qsharp.summary: Given an array and a predicate that is defined
|
|
10
|
+
for the elements of the array, and checks if all elements of the
|
|
11
|
+
array satisfy the predicate.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# All function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function All<'T>(predicate : ('T -> Bool), array : 'T[]) : Bool
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a predicate that is defined
|
|
24
|
+
for the elements of the array, and checks if all elements of the
|
|
25
|
+
array satisfy the predicate.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### predicate
|
|
33
|
+
A function from `'T` to `Bool` that is used to check elements.
|
|
34
|
+
### array
|
|
35
|
+
An array of elements over `'T`.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
A `Bool` value of the AND function of the predicate applied to all elements.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
The following code checks whether all elements of the array are non-zero:
|
|
42
|
+
```qsharp
|
|
43
|
+
let allNonZero = All(x -> x != 0, [1, 2, 3, 4, 5]);
|
|
44
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Any
|
|
3
|
+
title: Any 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: Any
|
|
9
|
+
qsharp.summary: Given an array and a predicate that is defined
|
|
10
|
+
for the elements of the array, checks if at least one element of
|
|
11
|
+
the array satisfies the predicate.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Any function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function Any<'T>(predicate : ('T -> Bool), array : 'T[]) : Bool
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a predicate that is defined
|
|
24
|
+
for the elements of the array, checks if at least one element of
|
|
25
|
+
the array satisfies the predicate.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### predicate
|
|
33
|
+
A function from `'T` to `Bool` that is used to check elements.
|
|
34
|
+
### array
|
|
35
|
+
An array of elements over `'T`.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
A `Bool` value of the OR function of the predicate applied to all elements.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
```qsharp
|
|
42
|
+
let anyEven = Any(x -> x % 2 == 0, [1, 3, 6, 7, 9]);
|
|
43
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Chunks
|
|
3
|
+
title: Chunks 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: Chunks
|
|
9
|
+
qsharp.summary: Splits an array into multiple parts of equal length.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Chunks function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function Chunks<'T>(chunkSize : Int, array : 'T[]) : 'T[][]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Splits an array into multiple parts of equal length.
|
|
22
|
+
|
|
23
|
+
## Input
|
|
24
|
+
### chunkSize
|
|
25
|
+
The length of each chunk. Must be positive.
|
|
26
|
+
### array
|
|
27
|
+
The array to be split in chunks.
|
|
28
|
+
|
|
29
|
+
## Output
|
|
30
|
+
A array containing each chunk of the original array.
|
|
31
|
+
|
|
32
|
+
## Remarks
|
|
33
|
+
Note that the last element of the output may be shorter
|
|
34
|
+
than `chunkSize` if `Length(array)` is not divisible by `chunkSize`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.CircularlyShifted
|
|
3
|
+
title: CircularlyShifted 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: CircularlyShifted
|
|
9
|
+
qsharp.summary: Shift an array circularly left or right by a specific step size.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# CircularlyShifted function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function CircularlyShifted<'T>(stepCount : Int, array : 'T[]) : 'T[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Shift an array circularly left or right by a specific step size.
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'T
|
|
25
|
+
The type of the array elements.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### stepCount
|
|
29
|
+
The amount of positions by which the array elements will be shifted.
|
|
30
|
+
If this is positive, `array` is circularly shifted to the right.
|
|
31
|
+
If this is negative, `array` is circularly shifted to the left.
|
|
32
|
+
### array
|
|
33
|
+
Array to be circularly shifted.
|
|
34
|
+
|
|
35
|
+
## Output
|
|
36
|
+
An array `output` that is the `array` circularly shifted to the right or left
|
|
37
|
+
by the specified step size.
|
|
38
|
+
|
|
39
|
+
## Example
|
|
40
|
+
```qsharp
|
|
41
|
+
let array = [10, 11, 12];
|
|
42
|
+
// The following line returns [11, 12, 10].
|
|
43
|
+
let output = CircularlyShifted(2, array);
|
|
44
|
+
// The following line returns [12, 10, 11].
|
|
45
|
+
let output = CircularlyShifted(-2, array);
|
|
46
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.ColumnAt
|
|
3
|
+
title: ColumnAt 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: ColumnAt
|
|
9
|
+
qsharp.summary: Extracts a column from a matrix.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# ColumnAt function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function ColumnAt<'T>(column : Int, matrix : 'T[][]) : 'T[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Extracts a column from a matrix.
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
This function extracts a column in a matrix in row-wise order.
|
|
25
|
+
Extracting a row corresponds to element access of the first index
|
|
26
|
+
and therefore requires no further treatment.
|
|
27
|
+
|
|
28
|
+
## Type Parameters
|
|
29
|
+
### 'T
|
|
30
|
+
The type of each element of `matrix`.
|
|
31
|
+
|
|
32
|
+
## Input
|
|
33
|
+
### column
|
|
34
|
+
Column of the matrix
|
|
35
|
+
### matrix
|
|
36
|
+
2-dimensional matrix in row-wise order
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
```qsharp
|
|
40
|
+
let matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
|
41
|
+
let column = ColumnAt(0, matrix);
|
|
42
|
+
// same as: column = [1, 4, 7]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## See Also
|
|
46
|
+
- Microsoft.Quantum.Arrays.Transposed
|
|
47
|
+
- Microsoft.Quantum.Arrays.Diagonal
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Count
|
|
3
|
+
title: Count 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: Count
|
|
9
|
+
qsharp.summary: Given an array and a predicate that is defined
|
|
10
|
+
for the elements of the array, returns the number of elements
|
|
11
|
+
an array that consists of those elements that satisfy the predicate.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Count function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function Count<'T>(predicate : ('T -> Bool), array : 'T[]) : Int
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a predicate that is defined
|
|
24
|
+
for the elements of the array, returns the number of elements
|
|
25
|
+
an array that consists of those elements that satisfy the predicate.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### predicate
|
|
33
|
+
A function from `'T` to Boolean that is used to filter elements.
|
|
34
|
+
### array
|
|
35
|
+
An array of elements over `'T`.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
The number of elements in `array` that satisfy the predicate.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
```qsharp
|
|
42
|
+
let evensCount = Count(x -> x % 2 == 0, [1, 3, 6, 7, 9]);
|
|
43
|
+
// evensCount is 1.
|
|
44
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Diagonal
|
|
3
|
+
title: Diagonal 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: Diagonal
|
|
9
|
+
qsharp.summary: Returns an array of diagonal elements of a 2-dimensional array
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Diagonal function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function Diagonal<'T>(matrix : 'T[][]) : 'T[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Returns an array of diagonal elements of a 2-dimensional array
|
|
22
|
+
|
|
23
|
+
## Description
|
|
24
|
+
If the 2-dimensional array has not a square shape, the diagonal over
|
|
25
|
+
the minimum over the number of rows and columns will be returned.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of each element of `matrix`.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### matrix
|
|
33
|
+
2-dimensional matrix in row-wise order.
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
```qsharp
|
|
37
|
+
let matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
|
38
|
+
let diagonal = Diagonal(matrix);
|
|
39
|
+
// same as: column = [1, 5, 9]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## See Also
|
|
43
|
+
- Microsoft.Quantum.Arrays.Transposed
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.DrawMany
|
|
3
|
+
title: DrawMany 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: DrawMany
|
|
9
|
+
qsharp.summary: Repeats an operation for a given number of samples, collecting its outputs
|
|
10
|
+
in an array.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# DrawMany operation
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
operation DrawMany<'TInput, 'TOutput>(op : ('TInput => 'TOutput), nSamples : Int, input : 'TInput) : 'TOutput[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Repeats an operation for a given number of samples, collecting its outputs
|
|
23
|
+
in an array.
|
|
24
|
+
|
|
25
|
+
## Input
|
|
26
|
+
### op
|
|
27
|
+
The operation to be called repeatedly.
|
|
28
|
+
### nSamples
|
|
29
|
+
The number of samples of calling `op` to collect.
|
|
30
|
+
### input
|
|
31
|
+
The input to be passed to `op`.
|
|
32
|
+
|
|
33
|
+
## Type Parameters
|
|
34
|
+
### TInput
|
|
35
|
+
The type of input expected by `op`.
|
|
36
|
+
### TOutput
|
|
37
|
+
The type of output returned by `op`.
|
|
38
|
+
|
|
39
|
+
## Example
|
|
40
|
+
The following samples an alternating array of results.
|
|
41
|
+
```qsharp
|
|
42
|
+
use qubit = Qubit();
|
|
43
|
+
let results = Microsoft.Quantum.Arrays.DrawMany(q => {X(q); M(q)}, 3, qubit);
|
|
44
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Enumerated
|
|
3
|
+
title: Enumerated 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: Enumerated
|
|
9
|
+
qsharp.summary: Given an array, returns a new array containing elements of the original
|
|
10
|
+
array along with the indices of each element.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Enumerated function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function Enumerated<'TElement>(array : 'TElement[]) : (Int, 'TElement)[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Given an array, returns a new array containing elements of the original
|
|
23
|
+
array along with the indices of each element.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'TElement
|
|
27
|
+
The type of elements of the array.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### array
|
|
31
|
+
An array whose elements are to be enumerated.
|
|
32
|
+
|
|
33
|
+
## Output
|
|
34
|
+
A new array containing elements of the original array along with their
|
|
35
|
+
indices.
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
The following `for` loops are equivalent:
|
|
39
|
+
```qsharp
|
|
40
|
+
for (idx in IndexRange(array)) {
|
|
41
|
+
let element = array[idx];
|
|
42
|
+
...
|
|
43
|
+
}
|
|
44
|
+
for ((idx, element) in Enumerated(array)) { ... }
|
|
45
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Excluding
|
|
3
|
+
title: Excluding 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: Excluding
|
|
9
|
+
qsharp.summary: Returns an array containing the elements of another array,
|
|
10
|
+
excluding elements at a given list of indices.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Excluding function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function Excluding<'T>(remove : Int[], array : 'T[]) : 'T[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Returns an array containing the elements of another array,
|
|
23
|
+
excluding elements at a given list of indices.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'T
|
|
27
|
+
The type of the array elements.
|
|
28
|
+
|
|
29
|
+
## Input
|
|
30
|
+
### remove
|
|
31
|
+
An array of indices denoting which elements should be excluded.
|
|
32
|
+
from the output.
|
|
33
|
+
### array
|
|
34
|
+
Array of which the values in the output array are taken.
|
|
35
|
+
|
|
36
|
+
## Output
|
|
37
|
+
An array `output` such that `output[0]` is the first element
|
|
38
|
+
of `array` whose index does not appear in `remove`,
|
|
39
|
+
such that `output[1]` is the second such element, and so
|
|
40
|
+
forth.
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
```qsharp
|
|
44
|
+
let array = [10, 11, 12, 13, 14, 15];
|
|
45
|
+
// The following line returns [10, 12, 15].
|
|
46
|
+
let subarray = Excluding([1, 3, 4], array);
|
|
47
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Filtered
|
|
3
|
+
title: Filtered 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: Filtered
|
|
9
|
+
qsharp.summary: Given an array and a predicate that is defined
|
|
10
|
+
for the elements of the array, returns an array that consists of
|
|
11
|
+
those elements that satisfy the predicate.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Filtered function
|
|
15
|
+
|
|
16
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
17
|
+
|
|
18
|
+
```qsharp
|
|
19
|
+
function Filtered<'T>(predicate : ('T -> Bool), array : 'T[]) : 'T[]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Summary
|
|
23
|
+
Given an array and a predicate that is defined
|
|
24
|
+
for the elements of the array, returns an array that consists of
|
|
25
|
+
those elements that satisfy the predicate.
|
|
26
|
+
|
|
27
|
+
## Type Parameters
|
|
28
|
+
### 'T
|
|
29
|
+
The type of `array` elements.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### predicate
|
|
33
|
+
A function from `'T` to Boolean that is used to filter elements.
|
|
34
|
+
### array
|
|
35
|
+
An array of elements over `'T`.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
An array `'T[]` of elements that satisfy the predicate.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
The following code creates an array that contains only even numbers.
|
|
42
|
+
```qsharp
|
|
43
|
+
Filtered(x -> x % 2 == 0, [0, 1, 2, 3, 4])
|
|
44
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.FlatMapped
|
|
3
|
+
title: FlatMapped 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: FlatMapped
|
|
9
|
+
qsharp.summary: Given an array and a function that maps an array element to some output
|
|
10
|
+
array, returns the concatenated output arrays for each array element.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# FlatMapped function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function FlatMapped<'TInput, 'TOutput>(mapper : ('TInput -> 'TOutput[]), array : 'TInput[]) : 'TOutput[]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Given an array and a function that maps an array element to some output
|
|
23
|
+
array, returns the concatenated output arrays for each array element.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'TInput
|
|
27
|
+
The type of `array` elements.
|
|
28
|
+
### 'TOutput
|
|
29
|
+
The `mapper` function returns arrays of this type.
|
|
30
|
+
|
|
31
|
+
## Input
|
|
32
|
+
### mapper
|
|
33
|
+
A function from `'TInput` to `'TOutput[]` that is used to map array elements.
|
|
34
|
+
### array
|
|
35
|
+
An array of elements.
|
|
36
|
+
|
|
37
|
+
## Output
|
|
38
|
+
An array of `'TOutput[]` which is the concatenation of all arrays generated by
|
|
39
|
+
the mapping function.
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
The following code creates an array with each element of the input array repeated twice.
|
|
43
|
+
```qsharp
|
|
44
|
+
let repeatedPairs = FlatMapped(x -> Repeated(x, 2), [1, 2, 3]);
|
|
45
|
+
// repeatedPairs is [1, 1, 2, 2, 3, 3].
|
|
46
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Flattened
|
|
3
|
+
title: Flattened 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: Flattened
|
|
9
|
+
qsharp.summary: Given an array of arrays, returns the concatenation of all arrays.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Flattened function
|
|
13
|
+
|
|
14
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
15
|
+
|
|
16
|
+
```qsharp
|
|
17
|
+
function Flattened<'T>(arrays : 'T[][]) : 'T[]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Summary
|
|
21
|
+
Given an array of arrays, returns the concatenation of all arrays.
|
|
22
|
+
|
|
23
|
+
## Type Parameters
|
|
24
|
+
### 'T
|
|
25
|
+
The type of `array` elements.
|
|
26
|
+
|
|
27
|
+
## Input
|
|
28
|
+
### arrays
|
|
29
|
+
Array of arrays.
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
Concatenation of all arrays.
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
```qsharp
|
|
36
|
+
let flattened = Flattened([[1, 2], [3], [4, 5, 6]]);
|
|
37
|
+
// flattened = [1, 2, 3, 4, 5, 6]
|
|
38
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
uid: Microsoft.Quantum.Arrays.Fold
|
|
3
|
+
title: Fold 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: Fold
|
|
9
|
+
qsharp.summary: Iterates a function `f` through an array `array`, returning
|
|
10
|
+
`f(...f(f(initialState, array[0]), array[1]), ...)`.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Fold function
|
|
14
|
+
|
|
15
|
+
Namespace: [Microsoft.Quantum.Arrays](xref:Microsoft.Quantum.Arrays)
|
|
16
|
+
|
|
17
|
+
```qsharp
|
|
18
|
+
function Fold<'State, 'T>(folder : (('State, 'T) -> 'State), state : 'State, array : 'T[]) : 'State
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Summary
|
|
22
|
+
Iterates a function `f` through an array `array`, returning
|
|
23
|
+
`f(...f(f(initialState, array[0]), array[1]), ...)`.
|
|
24
|
+
|
|
25
|
+
## Type Parameters
|
|
26
|
+
### 'State
|
|
27
|
+
The type of states the `folder` function operates on, i.e., accepts as its first
|
|
28
|
+
argument and returns.
|
|
29
|
+
### 'T
|
|
30
|
+
The type of `array` elements.
|
|
31
|
+
|
|
32
|
+
## Input
|
|
33
|
+
### folder
|
|
34
|
+
A function to be folded over the array.
|
|
35
|
+
### state
|
|
36
|
+
The initial state of the folder.
|
|
37
|
+
### array
|
|
38
|
+
An array of values to be folded over.
|
|
39
|
+
|
|
40
|
+
## Output
|
|
41
|
+
The final state returned by the folder after iterating over
|
|
42
|
+
all elements of `array`.
|
|
43
|
+
|
|
44
|
+
## Example
|
|
45
|
+
```qsharp
|
|
46
|
+
let sum = Fold((x, y) -> x + y, 0, [1, 2, 3, 4, 5]); // `sum` is 15.
|
|
47
|
+
```
|