From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 368D0BBAF for ; Tue, 5 Aug 2008 14:29:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhAJANjhl0hQRFuwgGdsb2JhbACKc4ZFAQEQnHY X-IronPort-AV: E=Sophos;i="4.31,310,1215381600"; d="scan'208";a="15736063" Received: from furbychan.cocan.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 05 Aug 2008 14:16:09 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1KQLSK-0006ob-HX; Tue, 05 Aug 2008 13:16:00 +0100 Date: Tue, 5 Aug 2008 13:16:00 +0100 To: Brighten Godfrey Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Getting an element of a hashtable: simple ... or is it? Message-ID: <20080805121600.GB25452@annexia.org> References: <94C5D65F-7CA4-48FF-B4AA-E88E82F6C8E1@cs.berkeley.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <94C5D65F-7CA4-48FF-B4AA-E88E82F6C8E1@cs.berkeley.edu> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; hashtable:01 hashtable:01 hashtbl:01 wrote:01 exception:01 caml-list:01 data:02 data:02 element:03 element:03 guess:04 tue:06 probably:07 red:92 structure:07 On Tue, Aug 05, 2008 at 05:05:46AM -0700, Brighten Godfrey wrote: > Suppose you are given a data structure, and you want to retrive one > element -- any one element. Sounds simple... and it is, if you have > a list (List.hd list) or an array (arr.(0)). But how about a > hashtable, if we don't know a priori any of the keys in the hashtable? It's very unclear what you're trying to do. For List and Array those methods won't work if the data structure is empty, but I guess that's expected. Hashtbl isn't designed with the "get an/any element" usage in mind -- your loop/exception is probably the best way given that you've made a poor choice of data structure in the first place. But this still comes back to the question, what are you trying to do? Rich. -- Richard Jones Red Hat