The printing function is not working in https://try.ocamlpro.com/

Hi
why this function is not printing and working . i want to use it to print the numbers
let x=5
Printf.printf " the value of x=%d"
Returen of this function is unit ()

The return value always going to be (). But this is different from what gets printed. Sometimes in the toplevel (REPL), they get mixed together. But also you didn’t pass x to the function.

val x : int = 5
# Printf.printf " the value of x=%d";;
- : int -> unit = <fun>
# Printf.printf " the value of x=%d" x;;
the value of x=5- : unit = ()

Hi, thank for your reponse
i can not undersatnd why when i put the same code is not working

Printf.printf “the value of function x=%d” x;;

  • : unit = ()

i am using https://try.ocamlpro.com/ to use my code on online ocaml

funny thing, it seems that printf in try.ocamlpro.com prints to the
Javascript console (and not to the REPL)

​

2 Likes

thank you very much its not my fault