Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-10-24 (06:54)
From: Dustin Sallings <dustin@s...>
Subject: Re: [Caml-list] newbie type problem

On Thursday, Oct 23, 2003, at 16:32 US/Pacific, David Brown wrote:

> It is a little hard, since I can't tell what you're trying to 
> represent.
> Also, a hashtable might not be the best data structure.
> What information are you trying to keep track of?  A hashtable maps
> objects of one type to another.  If you wanted the pb_counts field to
> map strings to int refs (so you can change the refs), you could use a
>    pb_counts: (string, int ref) Hashtbl.t

	Yeah, this is the kind of thing I was looking for.  I tried a variety 
of things I thought looked like this.

> without more information, it is hard to tell if that is what you really
> want.
> Ocaml also has arrays, maps, sets, and there are numerous libraries 
> with
> other structures as well.

	When picking up a language, there always seems to be a bit of effort 
required to learn how to read the docs.  The docs for Map are pretty 
much empty, but it does link to the source, which gives me a good idea.

	I'm not sure how to express my data structure...  I'm parsing a log 
file that contains start and stop timestamps for various transaction 
types.  I want to count up the number and total time of each of these 
transactions and group them by timestamp rounded to the nearest five 
minutes.  So, it'd look something like this:

{ 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.

	Thanks for your help.

SPY                      My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: