IterateThroughCartesianPower operation
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
反馈
提交和查看相关反馈