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 KAA28924; Thu, 20 Feb 2003 10:43:51 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA28833 for ; Thu, 20 Feb 2003 10:43:50 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1K9hhT16123; Thu, 20 Feb 2003 10:43:44 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA28797; Thu, 20 Feb 2003 10:43:43 +0100 (MET) Date: Thu, 20 Feb 2003 10:43:43 +0100 From: Xavier Leroy To: Oliver Bandel Cc: caml-list@inria.fr Subject: Re: [Caml-list] Hashtbl.keys Message-ID: <20030220104343.B27056@pauillac.inria.fr> References: <20030218180341.GA267@first.in-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20030218180341.GA267@first.in-berlin.de>; from oliver@first.in-berlin.de on Tue, Feb 18, 2003 at 07:03:41PM +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Well... and Hashtbl.iter seems to work on *all* antries in the > *whole* hash-table, that is: A Hastbl.find_all for each of the > keys in that table. > At least it is, how I understand the decription in the manual. > > Well, but Hashtbl.iter is used for unit-functions. > But I need bool-functions, and maybe other tyopes > too. See Hashtbl.fold, which supports traversing all entries of a hashtable and build a result of any type. For instance: > So, Hashtbl.keys would have the following type: > > ('a, 'b) t -> key 'a list let keys h = Hashtbl.fold (fun key data accu -> key :: accu) h [] > Wouldn't it a good idea to add such a > function "get all keys of a hashtable" > into the hashtbl-module? (And a "get all values..." to?) There would be disagreement as what the return type of these functions should be: lists, sets, etc. But you can easily write them with Hashtbl.fold. - Xavier Leroy ------------------- 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