Created
December 6, 2016 08:39
-
-
Save prepor/ff6541fe9cfb0a18f7f5c59119644dd2 to your computer and use it in GitHub Desktop.
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 state = Init | Started | Stopped | |
| type init_event = InitStart | InitStop | |
| type started_event = StartedStop | |
| type stopped_event = StoppedStart | |
| let init_event () = | |
| List.nth [InitStart; InitStop] (Random.int 1) | |
| let started_event () = StartedStop | |
| let stopped_event () = StoppedStart | |
| let apply = function | |
| | Init -> begin | |
| match init_event () with | |
| | InitStart -> Started | |
| | InitStop -> Stopped end | |
| | Started -> begin | |
| match started_event () with | |
| | StartedStop -> Stopped end | |
| | Stopped -> begin | |
| match stopped_event () with | |
| | StoppedStart -> Started end | |
| let () = | |
| let rec tick s = | |
| tick (apply s) in | |
| tick Init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment