microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
minestarks/circuit-folding

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

samples/_circuit_diagrams/function_calls.qs

37lines · modecode

1operation Main() : Unit {
2 use qs = Qubit[2];
3
4 PrepareSomething(qs);
5 DoSomethingElse(qs);
6 DoSomethingElse(qs);
7 DoSomethingDifferent(qs);
8
9 MResetEachZ(qs);
10
11 ResetAll(qs);
12}
13
14operation PrepareSomething(qs : Qubit[]) : Unit {
15 for iteration in 1..5 {
16 H(qs[0]);
17 X(qs[0]);
18 CNOT(qs[0], qs[1]);
19 }
20}
21
22operation DoSomethingElse(qs : Qubit[]) : Unit {
23 for iteration in 1..5 {
24 H(qs[1]);
25 X(qs[0]);
26 X(qs[1]);
27 CNOT(qs[1], qs[0]);
28 }
29}
30
31operation DoSomethingDifferent(qs : Qubit[]) : Unit {
32 for iteration in 1..5 {
33 H(qs[0]);
34 Z(qs[0]);
35 CNOT(qs[0], qs[1]);
36 }
37}
38