Program.if_then

Program.if_then(classical_reg, if_program, else_program=None)[source]

If the classical register at index classical reg is 1, run if_program, else run else_program.

Equivalent to the following construction:

Parameters:
  • classical_reg (int) – The classical register to check as the condition
  • if_program (Program) – A Quil program to execute if classical_reg is 1
  • else_program (Program) – A Quil program to execute if classical_reg is 0. This argument is optional and defaults to an empty Program.
Returns:

The Quil Program with the branching instructions added.

Return type:

Program