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 LAA20114; Wed, 13 Jun 2001 11:51:07 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA20091 for caml-list@pauillac.inria.fr; Wed, 13 Jun 2001 11:51:06 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA18376 for ; Wed, 13 Jun 2001 10:46:40 +0200 (MET DST) Received: from pochi.inria.fr (pochi.inria.fr [128.93.8.128]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f5D8kaT17128; Wed, 13 Jun 2001 10:46:37 +0200 (MET DST) Received: (from mentre@localhost) by pochi.inria.fr (8.11.1/8.10.0) id f5D8kaL26938; Wed, 13 Jun 2001 10:46:36 +0200 X-Authentication-Warning: pochi.inria.fr: mentre set sender to David.Mentre@inria.fr using -f To: leary@nwlink.com Cc: Francois Thomasset , caml Subject: Re: [Caml-list] enums in OCaml? References: <20010612192126.B24440@jean> <200106130751.f5D7pbL11758@ionie.inria.fr> <20010613011853.A25131@jean> From: David Mentre Date: 13 Jun 2001 10:46:36 +0200 In-Reply-To: <20010613011853.A25131@jean> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk leary@nwlink.com writes: > I'm looking for something that would do the right thing when I do: > > printf ( "%d 23", Accelerate );; (* sorry if my syntax is off, I haven't > gotten too far with it yet *) Probably something like: # type enum = Accelerate | Other;; type enum = Accelerate | Other # let int_enum e = match e with | Accelerate -> 1 | Other -> 0;; val int_enum : enum -> int = # Printf.printf "%d 23\n" (int_enum Accelerate);; 1 23 - : unit = () But without further context, it is difficult to guess what you want (i.e. do the right thing). Maybe you should have a look at source code of standard libraries. They are remarkably concise and well written. For example, operations on lists (List module): http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/ocaml/stdlib/list.ml?rev=1.27&content-type=text/x-cvsweb-markup d. -- David.Mentre@inria.fr -- http://www.irisa.fr/prive/dmentre/ Opinions expressed here are only mine. ------------------- 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