RosettaCodeData/Task/Execute-HQ9+/OCaml/execute-hq9+.ocaml
2018-06-22 20:57:24 +00:00

9 lines
257 B
Text

let hq9p line =
let accumulator = ref 0 in
for i = 0 to (String.length line - 1) do
match line.[i] with
| 'h' | 'H' -> print_endline "Hello, world!"
| 'q' | 'Q' -> print_endline line
| '9' -> beer 99
| '+' -> incr accumulator
done