[Camllist] self and mutually recursive functions ?

Metalscan
 Pierre Weis
 Michel Quercia
 Pietro Abate
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:   (:) 
From:  Michel Quercia <michel.quercia@p...> 
Subject:  Re: [Camllist] self and mutually recursive functions ? 
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/tpoptinfo$ 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/tpoptinfo$ 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 = <fun> val g : int > 'a as 'a = <fun> # #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 camllistrequest@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/camlbugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners