Quantcast
Viewing latest article 12
Browse Latest Browse All 517

Iterating through a string using For loop

I am trying to iterate through the characters of string using for loop however I get the following error

let str = "Hello"for var=0 to (String.length str -1) do  let temp = String.get str vardone;;Error : Syntax error

I tried this code here

let str = "Hello";;for i = 0 to (String.length str -1) do    Printf.printf "%s" String.get str idone;;

and this is the error i get

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 

Viewing latest article 12
Browse Latest Browse All 517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>