Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] self and mutually recursive functions ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pietro Abate <abate@d...>
Subject: Re: [Caml-list] self and mutually recursive functions ?
On Thu, Oct 10, 2002 at 05:47:38PM +0200, Metalscan wrote:
> In each of them, there would be a match with one
> branch returning itself and the other one returning
> the other function.

do you want something like that ?

let rec f1 i =
    match i with
    | 1 -> f1 (i-1)
    | 2 -> f2 (i-1)
    | a -> let _ = Printf.printf "f1 = %d\n" a in a
and f2 j = 
    match j with 
    | 1 -> f2 (j-1)
    | 2 -> f1 (j-1)
    | a -> let _ = Printf.printf "f2 = %d\n" a in a
;; 

# f1 1;;
f1 = 0
- : int = 0
# f1 2;;
f2 = 0
- : int = 0

regards,
p

-- 
pgp key: 1024D/8A091922 2000-10-18 Pietro Abate <abate@arp.anu.edu.au>
Key fingerprint = 5111 D91B 5E0C 5CE6 FDA3  5EF4 6120 E18E 8A09 1922
public key avalaible via public key server at wwwkeys.eu.pgp.net
-------------------
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