microsoft / qsharp-language

Official repository for design of the quantum programming language Q# and its core libraries
MIT License
233 stars 54 forks source link

Code sample in Iterations throws exceptions #69

Closed tcNickolas closed 3 years ago

tcNickolas commented 3 years ago
  1. mutable results = new (Int, Results)[Length(qubits)]; should have type Result as the second tuple element.
  2. The second loop (the one that measures the qubits) should either iterate from 0 to Length - 1 or use index - 1 as qubit index in the array, otherwise it throws ArgumentOutOfRangeException.
  3. Not a bug per se, but it looks weird to allocate an empty array of the right size and then append new elements to it; it seems more common either to allocate an array of size 0 and append to it or to allocate an empty array of the right size and then overwrite its elements with measurement results.
bamarsha commented 3 years ago

Thanks! Yeah, I agree with those issues in the example. For reference, here is the link to the code sample.