How can I prevent "- : unit = ()" from appearing after my output in the ocaml toplevel?
This code
for i=0 to 5 do print_string "a" done;;
will output
aaaaaa- : unit = ()
But how can I output just "aaaaaa" without outputting the value of for-e开发者_如何学Goxpression?
You are not really printing the value of the expression; it's just that you are within the session of the interpreter, which by default prints the value/type of the evaluated expression. If you compiled your program it would just print the a's.
You could compile your program; this way you won't get the type information from the interpreter -- which is : unit = ()
精彩评论