0

I've a problem with a loop for. In this program,

let f s = 
  for i = 0 to ((String.length s) - 1) do 
    print_char s.[i];
  done;;

For some reasons, I want to change the variable i (increase,dicrease) but this variable is not mutable and I don't see how I can change the pointer on the string s. I think to an another function which but I don't know if is the good idea ..

afk
  • 563
  • 2
  • 5
  • 12
  • From what I remember of Ocaml(a caml varient), it wasn't designed to do very much assignment(such as increasing and decreasing). It's a functional language, not an iterative one – Sam I am says Reinstate Monica Apr 24 '13 at 21:10
  • Yes I know that but it isn't a way to change the i pointer on the string s ? – afk Apr 24 '13 at 21:13
  • yeah it's FP.. why do you want to change the "variable"? you're probably approaching the problem from a wrong direction. – Karoly Horvath Apr 24 '13 at 21:15
  • I don't want to move characters by characters. I want to jump in the string at the i+2 or i+3 position – afk Apr 24 '13 at 21:18

0 Answers0