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 BAA25493; Sat, 16 Jun 2001 01:42:45 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA25410 for ; Sat, 16 Jun 2001 01:42:31 +0200 (MET DST) Received: from localhost.localdomain (Mix-Montsouris-109-3-38.abo.wanadoo.fr [193.248.102.38]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f5FNgKX09586 for ; Sat, 16 Jun 2001 01:42:20 +0200 (MET DST) Received: (qmail 5625 invoked by uid 1001); 15 Jun 2001 23:36:18 -0000 Date: Sat, 16 Jun 2001 01:36:18 +0200 From: Berke Durak To: caml Subject: [Caml-list] Weird types Message-ID: <20010616013618.A13696@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I have a type type ('a,'b,'c,'d,'e,'f,'g) sigma = I of 'a * 'b * 'c * 'd * 'e * 'f * 'g | T of ('b,'a,'c,'d,'e,'f,'g) sigma | P of ('b,'c,'d,'e,'f,'g,'a) sigma and a function let rec gamma = function I _ -> 0 | T x -> 1 + (gamma x) | P x -> 1 + (gamma x) and want a version of gamma that works on the following data type t1 = X1 and t2 = X2 and t3 = X3 and t4 = X4 and t5 = X5 and t6 = X6 and t7 = X7 let data = I(X1,X2,X3,X4,X5,X6,X7) and that is under 10K of length. Any clever way to solve this ? I admit that this is an expressly constructed pathologic case. However it's derived from the much less pathologic following case : type min = Min of (int -> int -> int) type max = Max of (int -> int -> int) type ('a,'b,'c) game_tree = Leaf of 'c | Branch of 'a * 'c * ('b,'a,'c) game_tree list type ('a,'b,'c) game = Game of 'a * 'b * ('a,'b,'c) game_tree let min = Min(compare) let max = Max((fun x y -> - compare x y)) let bad_game = Game(min,max, Branch(max,None, [Branch(max,None,[Leaf(None)]); Branch(max,None,[Branch(min,None,[Leaf(None)])])]) let a_game = Game(min,max, Branch(max, ref None, [Branch(min, ref None, [Leaf(ref (Some 6.12389)); Leaf(ref (Some 3.49348))]); Branch(min, ref None, [Leaf(ref (Some 1.372645)); Branch(max, ref None, [Leaf(ref (Some 1.481743)); Leaf(ref (Some 2.481743)); Leaf(ref (Some 3.481743)); Leaf(ref (Some 4.481743))])])]) where the typing is used to ensure that each level in the game tree contains only nodes of the same type and that no two consecutive levels are of the same type. -- Berke Durak ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr