I’m learning Ocaml at school and I got an exam tomorrow but there is something I still don’t understand. I think my code is correct but the problem come from the type of my function, Ocaml return an error saying : Error: This expression has type char but an expression was expected of type string aiming at (str.[i]). The fact is that I want the first function encadree to understand the © is a character but when I define the function Ocaml return : val encadree : string -> string = instead of : val encadree : char -> string =
Do you know if there is anything to define the type of a var by himself, thank’s !
Here is my code :
let encadree © : string = “[”^c^"]";;
let crochete (str) = let rep = ref “” in
for i = 0 to String.length(str) do
and here is a screen of the exercise if you speak a little of french