Program.while_do

Program.while_do(classical_reg, q_program)[source]

While a classical register at index classical_reg is 1, loop q_program

Equivalent to the following construction:

WHILE [c]:
   instr...
=>
  LABEL @START
  JUMP-UNLESS @END [c]
  instr...
  JUMP @START
  LABEL @END
Parameters:
  • classical_reg (int) – The classical register to check
  • q_program (Program) – The Quil program to loop.
Returns:

The Quil Program with the loop instructions added.

Return type:

Program