let rec h () = ... then h ()... will define (and apply a function) Iet rec value = .. value is something totally different În joi, 17 mar. 2016 la 17:33, Antoine Rimlet a scris: > Hi, > > I'm trying to write a recursive function that would work like a for loop: > > let rec forloop g v u = > let x = ref v in let rec h = begin g !x; x := !x + 1; if !x <= u then h > end > in h;; > > I know this is horribly far from the functional spirit, but anyway ocaml > complains that "This kind of expression is not allowed as right-hand side > of `let rec'". It seems to me that this function definition has a meaning, > so why is it rejected? What should I do to get it accepted by ocaml? > > Many thanks in advance, > > Antoine > >