Could you please show me how to get user's input in Ocaml-top?
It can be found in this link: http://www.typerex.org/ocaml-top.html
I'm a beginner in Ocaml and I'm trying to get the user's input to run this example
This is the code:
let rec hilo n =
let () = print_string "type a number: " in
let i = read_int ()
in
if i = n then
let () = print_string "BRAVO" in
let () = print_newline ()
in print_newline ()
else
let () =
if i < n then
let () = print_string "Higher"
in print_newline ()
else
let () = print_string "Lower"
in print_newline ()
in hilo n ;;
But the program stop at Type a number
This is not really possible. OCaml-top sends its commands to the ocaml interpreter through the standard input, and read_int reads inputs on stdin also. This problem is tracked at https://github.com/OCamlPro/ocaml-top/issues/45