922 B
922 B
0.1. Print
If we want to print something in CAML, we have to use this structure
# print_string "Hello World!";;
Hello! - : unit=()
# print_int ;;
-: int -> unit = <fun>
(*expression*)
# print_[type] [things to print];;
[things to print] -: unit=()
Difference between compiler and interpreter for print
flowchart LR
A[CAML] -- compile --> B[ ] -- exec --> C[standard output] & D[standard error] ~~~ E(on your terminal)
flowchart LR
A[CAML] -- interpreter --> B[standard error] & C[standard output] & D[CAML answer] ~~~ E(in the interpreter interface)
To print something and create a new line for the CAML evaluation
# print_endline "toto";;
toto
-: unit = ()
To just print a newline
# print_newline();;
-: unit = ()
0.2. Sequence of prints
# print_string "The answer is: "; print_int 42;;
The answer is: 42 -: unit = ()