Created
June 16, 2020 13:54
-
-
Save mariano-aguero/b8ebbd64fe92d5e22ac65a82b47d530c to your computer and use it in GitHub Desktop.
Counter example
This file contains hidden or 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
type action is | |
| Increment of (int) | |
| Decrement of (int) | |
| Reset of (unit) | |
type store is int | |
type return is list (operation) * store | |
const emptyOps: list(operation) = list end | |
function increment (const value : int ; var store : store) : return is | |
block { | |
store := store + value | |
} with (emptyOps, store); | |
function decrement (const value : int ; var store : store) : return is | |
block { | |
store := store - value | |
} with (emptyOps, store); | |
function reset (var store : store) : return is | |
block { | |
store := 0 | |
} with (emptyOps, store); | |
function main (const action : action ; const store : store) : return is | |
block { | |
skip | |
} with case action of | |
| Increment(n) -> increment(n, store) | |
| Decrement(n) -> decrement(n, store) | |
| Reset(n) -> reset(store) | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment