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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Brown <caml-list@d...>
Subject: Re: [Caml-list] newbie type problem
On Thu, Oct 23, 2003 at 11:54:07PM -0700, Dustin Sallings wrote:

> { 0: <
> 	pb_counts = { "T1": 23, "T2": 43 }
> 	pb_times = { "T1": 291, "T2": 92 }
> 	>
>   300: <
> 	pb_counts = { "T1": 29, "T2": 50 }
> 	pb_times = { "T1": 202, "T2": 87 }
> 	>
> }
> 
> 	When I spell it out that way, it looks a little less than optimal.  
> However, this is more of a learning tool at this point.

You may want to consider putting the data for a given transaction type
into its own type, and having that be the target of the hashtbl.

   type transaction_info = {
     mutable counts : int;
     mutable times : int;
   }

Then your results could just be a

   (int * (string, transaction_info) Hashtbl.t) list

Dave

BTW, this actually seems like a good problem for learning the language.
I seem to always choose things too difficult, and end up getting
frustrated.

BTW, I have found the .mli files for the libraries to be the best
documentation.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners