caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Weird types
@ 2001-06-15 19:35 Berke Durak
  0 siblings, 0 replies; 6+ messages in thread
From: Berke Durak @ 2001-06-15 19:35 UTC (permalink / raw)
  To: caml

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


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [Caml-list] Weird types
@ 2001-06-15 23:36 Berke Durak
  2001-06-16 17:37 ` Tyng-Ruey Chuang
  0 siblings, 1 reply; 6+ messages in thread
From: Berke Durak @ 2001-06-15 23:36 UTC (permalink / raw)
  To: caml

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-06-19  7:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-15 19:35 [Caml-list] Weird types Berke Durak
2001-06-15 23:36 Berke Durak
2001-06-16 17:37 ` Tyng-Ruey Chuang
2001-06-18  7:14   ` Jean-Christophe Filliatre
2001-06-18  8:04     ` Tyng-Ruey Chuang
2001-06-18 12:15       ` Didier Remy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).