我正在尝试使用for循环遍历字符串的字符但是我得到以下错误
let str = "Hello"
for var=0 to (String.length str -1) do
let temp = String.get str var
done;;
Error : Syntax error
我在这里尝试了这段代码
let str = "Hello";;
for i = 0 to (String.length str -1) do
Printf.printf "%s" String.get str i
done;;
这是我得到的错误
Error: This expression has type
('a -> 'b -> 'c, out_channel, unit, unit, unit, 'a -> 'b -> 'c)
CamlinternalFormatBasics.fmt
but an expression was expected of type
('a -> 'b -> 'c, out_channel, unit, unit, unit, unit)
CamlinternalFormatBasics.fmt
Type 'a -> 'b -> 'c is not compatible with type unit