IterateThroughCartesianPower 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 an operation for each index in the Cartesian power of an integer range.
operation IterateThroughCartesianPower (power : Int, bound : Int, op : (Int[] => Unit)) : Unit
Description
Iteratively applies an operation for each element of a Cartesian power
of the range 0..(bound - 1)
.
Input
power : Int
The Cartesian power to which the range 0..(bound - 1)
should be
raised.
bound : Int
A specification of the range to be iterated over, given as the length of the range.
op : Int[] => Unit
An operation to be called for each element of the given Cartesian power.
Output : Unit
Example
Given an operation op
, the following two snippets are equivalent:
IterateThroughCartesianPower(2, 3, op);
op([0, 0]);
op([1, 0]);
op([2, 0]);
op([0, 1]);
// ..
op([2, 2]);
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