Remove deprecated `using` qubit allocation syntax (#777)
This commit is contained in:
Родитель
14071e2a04
Коммит
79ad94dc7b
|
@ -341,7 +341,7 @@
|
|||
"source": [
|
||||
"<details>\n",
|
||||
" <summary><b>Click here for the complete answer validation code</b></summary>\n",
|
||||
"<code> using (y = Qubit()) {\n",
|
||||
"<code> use y = Qubit() {\n",
|
||||
" oracle(register, y);\n",
|
||||
" if (MResetZ(y) == One) {\n",
|
||||
" Message(\"Correct!\");\n",
|
||||
|
@ -437,7 +437,7 @@
|
|||
" GroversAlgorithm_Loop(register, oracle, iterationCount);\n",
|
||||
" set finalAnswer = ResultArrayAsBoolArray(MultiM(register));\n",
|
||||
" Message($\"Verifying answer {finalAnswer}\");\n",
|
||||
" using (y = Qubit()) {\n",
|
||||
" use y = Qubit() {\n",
|
||||
" oracle(register, y);\n",
|
||||
" if (MResetZ(y) == One) {\n",
|
||||
" set isAnswerCorrect = true;\n",
|
||||
|
@ -550,7 +550,7 @@
|
|||
"for (i in 1 .. 100) {\n",
|
||||
" GroversAlgorithm_Loop(register, oracle, iterationCount);\n",
|
||||
" let answer = ResultArrayAsBoolArray(MultiM(register));\n",
|
||||
" using (y = Qubit()) {\n",
|
||||
" use y = Qubit() {\n",
|
||||
" oracle(register, y);\n",
|
||||
" if (MResetZ(y) == One) {\n",
|
||||
" set successCount += 1;\n",
|
||||
|
|
|
@ -160,14 +160,14 @@
|
|||
"// The qubit is deallocated once it's not used any longer\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"> Before Q# 0.15 the syntax for qubit allocation was different:\n",
|
||||
"> An alternative syntax for qubit allocation defines the scope in which the allocated qubits are available explicitly:\n",
|
||||
"```c#\n",
|
||||
"// This statement allocates a qubit, and binds it to the variable q\n",
|
||||
"using (q = Qubit()) {\n",
|
||||
"use q = Qubit() {\n",
|
||||
" // You can work with the qubit here\n",
|
||||
" // ...\n",
|
||||
"}\n",
|
||||
"// The qubit is no longer allocated outside of the 'using' block\n",
|
||||
"// The qubit is no longer allocated outside of the 'use' block\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"Freshly allocated qubits start out in state $|0\\rangle$, and have to be returned to that state by the time they are released. If you attempt to release a qubit in any state other than $|0\\rangle$, your program will throw a `ReleasedQubitsAreNotInZeroStateException`. We will see why it is important later, when we look at multi-qubit systems."
|
||||
|
|
Загрузка…
Ссылка в новой задаче