summaryrefslogtreecommitdiff
path: root/Test/dafny0/ControlStructures.dfy
diff options
context:
space:
mode:
authorGravatar Rustan Leino <leino@microsoft.com>2011-05-30 22:01:35 -0700
committerGravatar Rustan Leino <leino@microsoft.com>2011-05-30 22:01:35 -0700
commit2730584ec8f127d950e5ee8884e8bc2a6e2d3db2 (patch)
tree0ad5c08d420cb71238542b7dc1aa218b4229aa63 /Test/dafny0/ControlStructures.dfy
parent7b8adafdc184fd812fbb26d4d4ca4aaf5f0d134a (diff)
Dafny: Translate general LHSs for var and := (not yet for call, no compilation yet)
Diffstat (limited to 'Test/dafny0/ControlStructures.dfy')
-rw-r--r--Test/dafny0/ControlStructures.dfy9
1 files changed, 3 insertions, 6 deletions
diff --git a/Test/dafny0/ControlStructures.dfy b/Test/dafny0/ControlStructures.dfy
index 5012e003..c46eee3a 100644
--- a/Test/dafny0/ControlStructures.dfy
+++ b/Test/dafny0/ControlStructures.dfy
@@ -96,8 +96,7 @@ method DutchFlag(A: array<int>, N: int, l: int, r: int) returns (result: int)
var pv := A[l];
var i := l;
var j := r-1;
- // swap A[l] and A[j]
- var tmp := A[l]; A[l] := A[j]; A[j] := tmp;
+ A[l], A[j] := A[j], A[l];
while (i < j)
invariant l <= i && i <= j && j < r;
@@ -110,11 +109,9 @@ method DutchFlag(A: array<int>, N: int, l: int, r: int) returns (result: int)
case pv <= A[j-1] =>
j := j - 1;
case A[j-1] < pv && pv < A[i] =>
- // swap A[j-1] and A[i]
- tmp := A[i]; A[i] := A[j-1]; A[j-1] := tmp;
+ A[j-1], A[i] := A[i], A[j-1];
assert A[i] < pv && pv < A[j-1];
- i := i + 1;
- j := j - 1;
+ i, j := i + 1, j - 1;
}
}
result := i;