From: Berke Durak <berke@altern.org>
To: caml <caml-list@inria.fr>
Subject: [Caml-list] Weird types
Date: Fri, 15 Jun 2001 21:35:16 +0200 [thread overview]
Message-ID: <20010615213516.A4942@localhost.localdomain> (raw)
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
next reply other threads:[~2001-06-18 8:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-15 19:35 Berke Durak [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010615213516.A4942@localhost.localdomain \
--to=berke@altern.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).