Last active
March 16, 2016 07:20
-
-
Save siburu/d42443462b7982e000df to your computer and use it in GitHub Desktop.
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
(* How to build: corebuild -pkg lwt.unix,lwt.syntax zundoko.native *) | |
open Lwt.Infix | |
let print_zundoko x = | |
Lwt_io.printl (if x then "Zun" else "Doko") | |
let print_kiyoshi () = | |
Lwt_list.iter_s | |
(fun (d,s) -> Lwt_unix.sleep d >> Lwt_io.print s) | |
[0.5,"Ki!"; 0.2,"Yo!"; 0.2,"Shi!"; 0.5,"\n"] | |
let rec loop i = | |
let x = Random.bool () in | |
print_zundoko x >> match x, i < 4 with | |
| true, _ -> Lwt_unix.sleep 0.1 >> loop (i+1) | |
| _, true -> Lwt_unix.sleep 0.1 >> loop 0 | |
| _, false -> print_kiyoshi () >> loop 0 | |
in Lwt_unix.run (loop 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment