I'm running Ocaml using utop, when I run the below function on a very long input:
let string_to_list str = let rec loop i limit = if i = limit then [] else (String.get str i) :: (loop (i + 1) limit) in loop 0 (String.length str);;
it returns the following error:
Stack overflow during evaluation (looping recursion?).
What would be the tail-recursive version of the function?