@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;
}