Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/1767997aea04c38385dc to your computer and use it in GitHub Desktop.
Save rightfold/1767997aea04c38385dc to your computer and use it in GitHub Desktop.
int abs(int x)
out (result) {
assert(result >= 0);
} body {
return x < 0 ? -x : x;
}
int f(int x)
in {
assert(x % 2 == 0);
} body {
return x / 2;
}
subset Nat of Int where * >= 0;
sub abs(Int $x) returns Nat {
$x < 0 ?? -$x : $x
}
subset Even of Int where * %% 2;
sub f(Even $x) {
return $x / 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment