Le Wed, 06 Nov 2013, Matej Kosik a écrit : > Hi, > > I would like to ask, how to do something like: > > let computed_format = Printf.sprintf "%%0%dd" 5 in > Printf.printf computed_format 42 > > The above code is rejected, because "computed_format" is of type "string" whereas > > ('a -> 'b, out_channel, unit) format = > ('a -> 'b, out_channel, unit, unit, unit, unit) format6 > > type was expected. > > My question is: is it possible to turn strings to values that would be accepted by Printf.printf as its first parameter? I don't think you can in general, because format strings are typed (so that the compiler can check the correctness of Printf.printf calls). However, you could try something along let computed_format = Printf.sprintf "%%0%d%d" 5 in print_string (computed_format 42) -- Simon