caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] let rec with let ref
@ 2016-03-17 15:32 Antoine Rimlet
  2016-03-17 15:37 ` vrotaru.md
  0 siblings, 1 reply; 4+ messages in thread
From: Antoine Rimlet @ 2016-03-17 15:32 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 750 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-18 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-17 15:32 [Caml-list] let rec with let ref Antoine Rimlet
2016-03-17 15:37 ` vrotaru.md
2016-03-18 11:36   ` Goswin von Brederlow
2016-03-18 11:55     ` Christoph Höger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).