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 IAA26809; Fri, 24 Oct 2003 08:54:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA32003 for ; Fri, 24 Oct 2003 08:54:12 +0200 (MET DST) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9O6sB100073 for ; Fri, 24 Oct 2003 08:54:11 +0200 (MET DST) Received: from spy.net (dustinti.west.spy.net [192.168.1.50]) by bob.west.spy.net (Postfix) with ESMTP id 9801658CF; Thu, 23 Oct 2003 23:54:08 -0700 (PDT) Date: Thu, 23 Oct 2003 23:54:07 -0700 Subject: Re: [Caml-list] newbie type problem Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: caml-list@inria.fr To: David Brown From: Dustin Sallings In-Reply-To: <20031023233239.GA4477@davidb.org> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 newbie:01 hashtable:01 hashtable:01 hashtbl:01 cae:99 arrays:01 ocaml:01 int:01 int:01 it'd:01 refs:02 refs:02 her:97 objects:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 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