1

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

using(q : Qubit[5]){
    myOp(q[2:3]);
}
Mahathi Vempati
  • 1,238
  • 1
  • 12
  • 33

1 Answers1

3

Yes, Q# supports array slicing: https://learn.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]);
}
Mariia Mykhailova
  • 1,987
  • 1
  • 9
  • 18