File: robot.ml

package info (click to toggle)
laby 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: ml: 3,823; xml: 133; sh: 115; pascal: 88; java: 70; perl: 69; php: 69; ansic: 68; javascript: 64; cpp: 59; makefile: 51; ruby: 48; python: 40; lisp: 32
file content (49 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
type tile =
  | laby_name_Void | laby_name_Wall | laby_name_Rock
  | laby_name_Web | laby_name_Exit | laby_name_Unknown

let act s f =
  Printf.fprintf stdout "%s\n%!" s;
  begin try
    begin match input_line stdin with
    | "quit" -> exit 0
    | x -> f x
    end
  with
  | End_of_file -> exit 1
  end

let laby_name_left () =
  act "left" ignore

let laby_name_right () =
  act "right" ignore

let laby_name_forward () =
  act "forward" ignore

let laby_name_take () =
  act "take" ignore

let laby_name_drop () =
  act "drop" ignore

let laby_name_escape () =
  act "escape" ignore

let laby_name_look () =
  act "look"
    begin function
    | "void" -> laby_name_Void
    | "wall" -> laby_name_Wall
    | "rock" -> laby_name_Rock
    | "web" -> laby_name_Web
    | "exit" -> laby_name_Exit
    | _ -> laby_name_Unknown
    end

let laby_name_say s =
  act ("say " ^ s) ignore

let _ =
  act "start" ignore