Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
improve diagnostics message when swapping array elements (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipw committed Jun 13, 2022
1 parent 5f9ba1c commit d46f8b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Standard/src/Arrays/Arrays.qs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ namespace Microsoft.Quantum.Arrays {
/// Swapped(1, 3, [0, 1, 2, 3, 4]);
/// ```
function Swapped<'T>(firstIndex : Int, secondIndex : Int, arr : 'T[]) : 'T[] {
Fact(firstIndex >= 0 and firstIndex < Length(arr), "First index is out of bounds");
Fact(secondIndex >= 0 and secondIndex < Length(arr), "Second index is out of bounds");
return arr
w/ firstIndex <- arr[secondIndex]
w/ secondIndex <- arr[firstIndex];
Expand Down

0 comments on commit d46f8b8

Please sign in to comment.