-\r
-(* Example usage of interactive: *)\r
-\r
-(* let interactive div conv cmds =\r
- let p = problem_of div conv in\r
- try (\r
- let p = List.fold_left (|>) p cmds in\r
- let rec f p cmds =\r
- let nth spl n = int_of_string (List.nth spl n) in\r
- let read_cmd () =\r
- let s = read_line () in\r
- let spl = Str.split (Str.regexp " +") s in\r
- s, let uno = List.hd spl in\r
- try if uno = "eat" then eat\r
- else if uno = "step" then step (nth spl 1) (nth spl 2)\r
- else failwith "Wrong input."\r
- with Failure s -> print_endline s; (fun x -> x) in\r
- let str, cmd = read_cmd () in\r
- let cmds = (" " ^ str ^ ";")::cmds in\r
- try\r
- let p = cmd p in f p cmds\r
- with\r
- | Done _ -> print_endline "Done! Commands history: "; List.iter print_endline (List.rev cmds)\r
- in f p []\r
- ) with Done _ -> ()\r
-;; *)\r
-\r
-(* interactive "x y"\r
- "@ (x x) (y x) (y z)" [step 0 1; step 0 2; eat]\r
-;; *)\r