This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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