mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Add check that there are samples for each language
This commit is contained in:
parent
f012a2aeee
commit
37f12e39a3
11 changed files with 171 additions and 3 deletions
45
website/index/samples/sample.qsharp.txt
Normal file
45
website/index/samples/sample.qsharp.txt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Run this cell using Ctrl+Enter (⌘+Enter on Mac)
|
||||
// Then run the next cell to see the output
|
||||
|
||||
open Microsoft.Quantum.Diagnostics;
|
||||
|
||||
operation QubitsDemo () : Unit {
|
||||
// This line allocates a qubit in state |0⟩
|
||||
use q = Qubit();
|
||||
Message("State |0⟩:");
|
||||
|
||||
// This line prints out the state of the quantum computer
|
||||
// Since only one qubit is allocated, only its state is printed
|
||||
DumpMachine();
|
||||
|
||||
// This line changes the qubit from state |0⟩ to state |1⟩
|
||||
X(q);
|
||||
|
||||
Message("State |1⟩:");
|
||||
DumpMachine();
|
||||
|
||||
// This line changes the qubit to state |-⟩ = (1/sqrt(2))(|0⟩ - |1⟩)
|
||||
// That is, this puts the qubit into a superposition
|
||||
// 1/sqrt(2) is approximately 0.707107
|
||||
H(q);
|
||||
|
||||
Message("State |-⟩:");
|
||||
DumpMachine();
|
||||
|
||||
// This line changes the qubit to state |-i⟩ = (1/sqrt(2))(|0⟩ - i|1⟩)
|
||||
S(q);
|
||||
|
||||
Message("State |-i⟩:");
|
||||
DumpMachine();
|
||||
|
||||
// This will put the qubit into an uneven superposition,
|
||||
// where the amplitudes of |0⟩ and |1⟩ have different moduli
|
||||
Rx(2.0, q);
|
||||
Ry(1.0, q);
|
||||
|
||||
Message("Uneven superposition state:");
|
||||
DumpMachine();
|
||||
|
||||
// This line returns the qubit to state |0⟩
|
||||
Reset(q);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue