Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Weird types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Berke Durak <berke@a...>
Subject: [Caml-list] Weird types
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