Skip to content

Instantly share code, notes, and snippets.

@AlgorithmsAreCool
Last active January 4, 2024 03:46
Show Gist options
  • Save AlgorithmsAreCool/25d2976ff4c42d5f9aec74af0c69bc82 to your computer and use it in GitHub Desktop.
Save AlgorithmsAreCool/25d2976ff4c42d5f9aec74af0c69bc82 to your computer and use it in GitHub Desktop.
Dafny Blog Snippets
type Timestamp = t: int| 0 <= t <= 9223372036854775808 //2^63
class Entity
{
var id : string
predicate isEqual(other : Entity)
reads this, other
{
id == other.id
}
}
method sumAndZero(arr: array<int>) returns (sum: nat)
requires forall i :: 0 <= i < arr.Length ==> arr[i] >= 0
modifies arr
{
var i: int := 0;
sum := 0;
//
while(i < arr.Length) {
sum := sum + arr[i];
arr[i] := arr[i];
i := i + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment