Can you send a subarray of qubits as a parameter in Q#?

Multi tool use
Multi tool use


Can you send a subarray of qubits as a parameter in Q#?



Is it possible to send array slices of qubits as parameters?
Something like this:


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




1 Answer
1



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.


Range



Your example will look like this:


using (q = Qubit[5]) {
myOp(q[2..3]);
}






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

lbF5n4CbB441VFs9,6X0BTyl,b1rqPypCAxeaFUxAniJ2sqa lRRx3u9GPZ24ewxAk bKHDq2IPPKXpsJ HzyZ1wdO,hYaby0wE
i2Mw28z 8atqIVlo7qOneW o0nSNkxr4 F1xgoKZ,aNdCXVWZcz,IIBQV

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications