@EntryPoint() operation MeasureOneQubit() : Result { // Allocate a qubit, by default it is in zero state use q = Qubit(); // We apply a Hadamard operation H to the state // It now has a 50% chance of being measured 0 or 1 H(q); // Now we measure the qubit in Z-basis. let result = M(qubit); // We reset the qubit before releasing it. if result == One { X(qubit); } // Finally, we return the result of the measurement. return result; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter