From: Hal Daume III <hdaume@ISI.EDU>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] generic data type -> int function
Date: Thu, 31 Mar 2005 06:33:12 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.44.0503310632530.715-100000@albini.isi.edu> (raw)
In-Reply-To: <20050330222737.GA443@first.in-berlin.de>
> On Tue, Mar 29, 2005 at 07:26:02PM -0800, Hal Daume III wrote:
> [...]
> > type etype = GPE | LOC | ORG | PER | NAE_e | BOS_e
> > type mtype = BAR | NAM | NOM | PRE | PRO | OTHER | NAE_m | BOS_m
> > type pairs = EM of etype*mtype | EE of etype*etype | MM of mtype*mtype
> > type pairs2 = EP of etype * pairs | MP of mtype * pairs
> >
> >
> > Corresponding output:
> >
> > let int_of_etype = function | GPE -> 0 | LOC -> 1 | ORG -> 2 | PER -> 3 | NAE_e -> 4 | BOS_e -> 5
> > let int_of_mtype = function | BAR -> 0 | NAM -> 1 | NOM -> 2 | PRE -> 3 | PRO -> 4 | OTHER -> 5 | NAE_m -> 6 | BOS_m -> 7
> > let int_of_pairs = function | EM (etype_0, mtype_1) -> 0 + 1 * (int_of_etype etype_0 + 6 * (int_of_mtype mtype_1)) | EE (etype_0, etype_1) -> 48 + 1 * (int_of_etype etype_0 + 6 * (int_of_etype etype_1)) | MM (mtype_0, mtype_1) -> 84 + 1 * (int_of_mtype mtype_0 + 8 * (int_of_mtype mtype_1))
> > let int_of_pairs2 = function | EP (etype_0, pairs_1) -> 0 + 1 * (int_of_etype etype_0 + 6 * (int_of_pairs pairs_1)) | MP (mtype_0, pairs_1) -> 888 + 1 * (int_of_mtype mtype_0 + 8 * (int_of_pairs pairs_1))
> [...]
>
> That's nice, but for what do you need this?
>
> Maybe this way is not necessary to go.
>
> So, what is this good for?!
I want to use complex data types as indices in arrays, essentially.
--
Hal Daume III | hdaume@isi.edu
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
next prev parent reply other threads:[~2005-03-31 14:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-24 16:38 Hal Daume III
2005-03-25 11:37 ` [Caml-list] " Jean-Christophe Filliatre
2005-03-30 3:26 ` Hal Daume III
2005-03-30 22:27 ` Oliver Bandel
2005-03-31 14:33 ` Hal Daume III [this message]
2005-03-31 17:01 ` Richard Jones
2005-03-31 18:04 ` Hal Daume III
2005-03-30 22:29 ` Oliver Bandel
2005-03-31 14:33 ` Hal Daume III
2005-03-25 19:15 ` Kim Nguyen
2005-03-29 7:29 ` Oliver Bandel
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=Pine.LNX.4.44.0503310632530.715-100000@albini.isi.edu \
--to=hdaume@isi.edu \
--cc=caml-list@yquem.inria.fr \
--cc=oliver@first.in-berlin.de \
/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