1

是否可以将量子比特的数组切片作为参数发送?像这样的东西:

using(q : Qubit[5]){
    myOp(q[2:3]);
}
4

1 回答 1

3

Yes, Q# supports array slicing: https://docs.microsoft.com/en-us/quantum/quantum-qr-expressions#array-expressions. You can use Range data type as an index to create a subarray of elements of the array indexed by elements of the range.

Your example will look like this:

using (q = Qubit[5]) {
    myOp(q[2..3]);
}
于 2018-07-02T15:57:18.600 回答