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 KAA14469; Mon, 18 Jun 2001 10:45:07 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA13453 for caml-list@pauillac.inria.fr; Mon, 18 Jun 2001 10:45:06 +0200 (MET DST) 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 VAA23007 for ; Fri, 15 Jun 2001 21:41:21 +0200 (MET DST) Received: from localhost.localdomain (Mix-Montsouris-110-1-48.abo.wanadoo.fr [193.248.188.48]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f5FJfBX07862 for ; Fri, 15 Jun 2001 21:41:11 +0200 (MET DST) Received: (qmail 14541 invoked by uid 1001); 15 Jun 2001 19:35:16 -0000 Date: Fri, 15 Jun 2001 21:35:16 +0200 From: Berke Durak To: caml Subject: [Caml-list] Weird types Message-ID: <20010615213516.A4942@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 : type min = Min of (int -> int -> int) type max = Max of (int -> int -> int) type ('a,'b,'c) game_tree = type 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 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