From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 0175D7EE34 for ; Thu, 17 Mar 2016 16:37:44 +0100 (CET) IronPort-PHdr: 9a23:JBknTBeOFkoHNVTB28fA5ikLlGMj4u6mDksu8pMizoh2WeGdxc+7Zh7h7PlgxGXEQZ/co6odzbGG4+a4BSdfud6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivcWPKFoQzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IeezAcq85Vb1VCig9eyBwvZWz9EqLcQzaz30AVWQQn1JyAg3B4Q2yCp73riz7sOc7wiifOcDqZb8xUDWmqaxsTUmswCwOMjp89GDMluRxirhaqVSvvU9R2YnRNcuLLv1id7nAO9YWbWVEV8dVESdGB8n0O5UVCPYIJ/seqoXVqF4HrB/4Dg6pUrC8ggRUj2P7iPVpm98qFhvLiUl5R4oD Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=vrotaru.md@gmail.com; spf=Pass smtp.mailfrom=vrotaru.md@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f54.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of vrotaru.md@gmail.com) identity=pra; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="vrotaru.md@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of vrotaru.md@gmail.com designates 209.85.215.54 as permitted sender) identity=mailfrom; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="vrotaru.md@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lf0-f54.google.com) identity=helo; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="postmaster@mail-lf0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DEAADBzepWizbXVdFeg2OBI6d6h2CKKwENgW+GDQKBNjgUAQEBAQEBAQEQAQEBCAsLCR8xgi2CFQEBAwESER0BGx4DAQsGBQQBBjcCAiEBAREBBQEcBgESIodvAQMKCKNZgTE+MYs2gWqCV4VnChknDVGDbAEBAQEGAQEBARYBBQoFhRd4hESCPoR+gToFh2qHAohoAYwLgXWPBocvhhYvgQ8eAQGCOB6BUTwuimMBAQE X-IPAS-Result: A0DEAADBzepWizbXVdFeg2OBI6d6h2CKKwENgW+GDQKBNjgUAQEBAQEBAQEQAQEBCAsLCR8xgi2CFQEBAwESER0BGx4DAQsGBQQBBjcCAiEBAREBBQEcBgESIodvAQMKCKNZgTE+MYs2gWqCV4VnChknDVGDbAEBAQEGAQEBARYBBQoFhRd4hESCPoR+gToFh2qHAohoAYwLgXWPBocvhhYvgQ8eAQGCOB6BUTwuimMBAQE X-IronPort-AV: E=Sophos;i="5.24,350,1454972400"; d="scan'208,217";a="208401567" Received: from mail-lf0-f54.google.com ([209.85.215.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 17 Mar 2016 16:37:43 +0100 Received: by mail-lf0-f54.google.com with SMTP id h198so45354061lfh.0 for ; Thu, 17 Mar 2016 08:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bJGkD9zyYrnaJb9Wp7bKQR6EiQT/ZQ2zkWPMIaT02A0=; b=x1vCfXs5HUmlCVxmyUwJn1SiEApXs+6SnIK5qmKCIo6LEuWjTwQQ1sbbLYv/jAD7/Z NXMTs1mllCyIbp5kxYN5NNBgWBeUnw/dUVO+D6LWfrWtHEUdRoUy9cwwMjiPo4USRqtc sMlHQOLLXIwo7dcoVP0MwK0yw8vHQd6bg8c4NdI1WQs+8++PzLBZVq+H2TumALbyKftY DxrAMJ+5ZIR+gjCvlaaV2m+6tVDRa3XSU0z09zVz64wynqDL5klweOYZXrPv1GMvEs4i AprASHm3rR+OF2KETzQQh7v2VrnY+QjiJm08v3QSHhRpVeL3h/U8Fp1vtnvGP1qTFjX1 jTLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=bJGkD9zyYrnaJb9Wp7bKQR6EiQT/ZQ2zkWPMIaT02A0=; b=XNHddHXwPYEtwyUT7Tf36gBrbvzKzjUB0b6LMhBWTkrXRINz83SCq88ykk9ffrw8R3 y5l6+Av8ySRgk2KcMIS+eSodJ99NfXKTenl98CVJBVYCDKBNMsfv4fqrayfxX2SmjuN8 45NrmARBCYZ9pR47+K4+lXmjAviR+QKxh3ZvvfKvnMq321CREcwWRN5E9yAWGdccvZVG V/T3HFuYo20As5y7sSGBYOqV4MyHLduVJdP6TU5MBOEKpeP2vRElYpI6KjEbjBem6a3x Tk1zt27+U9n5UnRv3KINVgaT62Xc41LgF+I2LiS/Qtuq43vkAFP1IFEgtjEbY09JUkX9 aEuQ== X-Gm-Message-State: AD7BkJJVW7e30Gg6UG3jYDsA3unFXip6Rmfsf2se2c+ZVYeUwxb8TgI0WilJqerTnMSOlC6t8Nce7U001umg9w== X-Received: by 10.25.206.132 with SMTP id e126mr4042884lfg.20.1458229062789; Thu, 17 Mar 2016 08:37:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "vrotaru.md@gmail.com" Date: Thu, 17 Mar 2016 15:37:32 +0000 Message-ID: To: Antoine Rimlet , caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a1142070649f0f9052e406926 Subject: Re: [Caml-list] let rec with let ref --001a1142070649f0f9052e406926 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable let rec h () =3D ... then h ()... will define (and apply a function) Iet rec value =3D .. value is something totally different =C3=8En 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 =3D > let x =3D ref v in let rec h =3D begin g !x; x :=3D !x + 1; if !x <=3D = 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 > > --001a1142070649f0f9052e406926 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
let rec h () =3D ... then h ()...=C2=A0

will define (and apply a function)=C2=A0

Iet rec value = =3D .. value =C2=A0

is something totally diffe= rent

=C3= =8En joi, 17 mar. 2016 la 17:33, Antoine Rimlet <antoine.rimlet@gmail.com> a scris:
Hi,

<= div>I'm trying to write a recursive function that would work like a for= loop:

let rec forloop g v u =3D
=C2=A0 let x =3D ref v in let rec h =3D begin g !x; x :=3D !x + 1; if !x= <=3D u then h end
=C2=A0 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 definit= ion has a meaning, so why is it rejected? What should I do to get it accept= ed by ocaml?

Many thanks in advance,
Antoine

--001a1142070649f0f9052e406926--