ApplyToEach operation
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
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
Input
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
'T
The target on which the operation acts.
Example
Prepare a three-qubit $\ket{+}$ state:
using (register = Qubit[3]) {
ApplyToEach(H, register);
}
See Also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for