I just stumbled upon some OCaml code that writes a loop like this:
let r = ref (f 0) in
for i = 1 to k - 1 do
r := f i * !r
done ;
!r
in
Which is interesting as I normally see this done using recursive functions in OCaml usually. Is there an advantage to one versus the other?