Execute HQ9+: Difference between revisions

+OCaml
(Added Julia language)
(+OCaml)
Line 1,274:
echo("Unknown command: ", token)
</lang>
 
=={{header|OCaml}}==
Regrettably, HQ9+ suffers from remarkably poor implementations, even though the spec nailed down every aspect of the language (apart from the exact lyrics of the '9' operation, this obviously to allow for localization.) What's worse, the only implementation linked from the spec, when it was accessible, was an OCaml work that <i>refused to implement the '+' operation</i> among its several other deviations. The following code borrows 'beer' from its page.
 
<lang ocaml>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</lang>
 
=={{header|PARI/GP}}==
Anonymous user