Q:

Concatenate string to integer in Ocaml

I would like a working version of this:
let x = "a" ^ 0;;

A:

As you undoubtedly noticed, you can only concatenate strings with other strings - not integers. So you'll have to convert your integer to a string before you can concatenate it. If the integer is really hard coded like in your example, you can just write "0" instead of 0 (in fact in your example you can just write "a0" and not concatenate anything at all).
If the integer is not a constant, you can use string_of_int to convert it to a string. So this will work:
let x = "a" ^ string_of_int my_integer

A:

You can also use the usual printf functions but it is much slower:
let x = Printf.sprintf "a%d" my_integer

