From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA12165 for caml-red; Mon, 12 Feb 2001 19:15:28 +0100 (MET) 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 OAA07026 for ; Mon, 12 Feb 2001 14:57:49 +0100 (MET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f1CDvnf19413 for ; Mon, 12 Feb 2001 14:57:49 +0100 (MET) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.11.1/jtpda-5.3.2) with ESMTP id f1CDvmu00958 ; Mon, 12 Feb 2001 14:57:48 +0100 (MET) Received: by pc803.lri.fr (8.9.3/feuille) id OAA19703 ; Mon, 12 Feb 2001 14:57:49 +0100 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14983.60381.251598.939523@pc803> Date: Mon, 12 Feb 2001 14:57:49 +0100 (MET) To: Ronaldo Carpio Cc: caml-list@inria.fr Subject: Re: newbie question (map/hashtbl size) In-Reply-To: <20010211052332.11155.qmail@web704.mail.yahoo.com> References: <20010211052332.11155.qmail@web704.mail.yahoo.com> X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: weis@pauillac.inria.fr In his message of Sat February 10, 2001, Ronaldo Carpio writes: > > How do you get the size of a hashtable or map? An esay solution is to use a reference and the iteration function provided with the datatype, like this: ====================================================================== # let hashtbl_size h = let n = ref 0 in Hashtbl.iter (fun _ _ -> incr n) h; !n;; val hashtbl_size : ('a, 'b) Hashtbl.t -> int = ====================================================================== Hope this helps, -- Jean-Christophe FILLIATRE mailto:Jean-Christophe.Filliatre@lri.fr http://www.lri.fr/~filliatr