ApplyToEach operation

Namespace: Microsoft.Quantum.Canon

Package: Microsoft.Quantum.Standard

Applies a single-qubit operation to each element in a register.

operation ApplyToEach<'T> (singleElementOperation : ('T => Unit), register : 'T[]) : Unit


singleElementOperation : 'T => Unit

Operation to apply to each qubit.

register : 'T[]

Array of qubits on which to apply the given operation.

Output : Unit

Type Parameters


The target on which the operation acts.


Prepare a three-qubit $\ket{+}$ state:

using (register = Qubit[3]) {
    ApplyToEach(H, register);

See Also