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:
IF [c]: instrA... ELSE: instrB... => JUMP-WHEN @THEN [c] instrB... JUMP @END LABEL @THEN instrA... LABEL @END
- Parameters
classical_reg (
Union
[MemoryReference
,Tuple
[str
,int
],List
[Any
],str
]) – The classical register to check as the conditionif_program (
Program
) – A Quil program to execute if classical_reg is 1else_program (
Optional
[Program
]) – A Quil program to execute if classical_reg is 0. This argument is optional and defaults to an empty Program.
- Return type
- Returns
The Quil Program with the branching instructions added.