From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA08695; Thu, 10 Oct 2002 20:00:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA08571 for ; Thu, 10 Oct 2002 20:00:09 +0200 (MET DST) Received: from postfix2-2.free.fr (postfix2-2.free.fr [213.228.0.140]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9AI08502070 for ; Thu, 10 Oct 2002 20:00:08 +0200 (MET DST) Received: from montchapet (dijon-1-a7-62-147-210-104.dial.proxad.net [62.147.210.104]) by postfix2-2.free.fr (Postfix) with ESMTP id 31C5F5F7C2 for ; Thu, 10 Oct 2002 20:00:04 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-1" From: Michel Quercia Reply-To: michel.quercia@prepas.org To: caml-list@inria.fr Subject: Re: [Caml-list] self and mutually recursive functions ? Date: Thu, 10 Oct 2002 19:59:37 +0200 User-Agent: KMail/1.4.1 References: <20021010154738.GA12586@rhinoceros.mts> In-Reply-To: <20021010154738.GA12586@rhinoceros.mts> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200210101959.37498.michel.quercia@prepas.org> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Le Jeudi 10 Octobre 2002 17:47, Metalscan a écrit : > Hello all of you ! > > I'm wondering wether it is possible or not to have > to functions defined wich are both mutually recursive > and simply recursive. > > In each of them, there would be a match with one > branch returning itself and the other one returning > the other function. I'm not sure to understand your problem. Do you want something like this ? let rec f(x) = if x = 0 then f else g and g(x) = if x = 1 then g else f;; Such a declaration will be rejected when submitted to ocaml, but can be accepted if you enable recursive types: quercia@montchapet:~/lycee/02/tp-opt-info$ ocaml Objective Caml version 3.06 # let rec f(x) = if x = 0 then f else g and g(x) = if x = 1 then g else f;; This expression has type int -> 'a but is here used with type 'a # #quit;; quercia@montchapet:~/lycee/02/tp-opt-info$ ocaml -rectypes Objective Caml version 3.06 # let rec f(x) = if x = 0 then f else g and g(x) = if x = 1 then g else f;; val f : int -> 'a as 'a = val g : int -> 'a as 'a = # #quit;; I doubt that the above f and g are actualy useful, but they are accepted anyway. Regards, -- Michel Quercia 23 rue de Montchapet, 21000 Dijon http://michel.quercia.free.fr (maths) http://pauillac.inria.fr/~quercia (informatique) mailto:michel.quercia@prepas.org ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners