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.1 required=5.0 tests=AWL 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 DAF77BC6B for ; Tue, 11 Dec 2007 17:38:24 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPNLXkfUGyocimdsb2JhbACBWo4PAQEBCAIIIgc X-IronPort-AV: E=Sophos;i="4.24,153,1196636400"; d="scan'208";a="6705728" Received: from smtp2-g19.free.fr ([212.27.42.28]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Dec 2007 17:38:24 +0100 Received: from smtp2-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp2-g19.free.fr (Postfix) with ESMTP id 596C112B72D for ; Tue, 11 Dec 2007 17:38:24 +0100 (CET) Received: from localhost.localdomain (c5850-a2-3-62-147-11-93.dial.proxad.net [62.147.11.93]) by smtp2-g19.free.fr (Postfix) with ESMTP id 4A22A12B6B2 for ; Tue, 11 Dec 2007 17:38:23 +0100 (CET) Date: Tue, 11 Dec 2007 16:42:09 +0100 From: Fabrice Marchant To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbl: get first n keys Message-ID: <20071211164209.5caed2a1@localhost.localdomain> In-Reply-To: <475E50E6.4060501@menta.net> References: <475E50E6.4060501@menta.net> X-Mailer: Claws Mail 2.10.0 (GTK+ 2.10.13; i486-pc-linux-gnu) X-Face: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; hashtbl:01 hash:01 iter:01 lacked:01 ocaml:01 iter:01 beginners:01 exception:01 exception:01 caml-list:01 groups:02 seems:03 element:03 raise:03 problem:05 > Please, could someone suggest a way to get "n" keys of a hash table? No > order nor other restriction about the keys, just "n " keys existing in > the table. > > A method based on "iter" and raise and exception when limit is reached > seems possible, but could be there are better options. Hi ! A particular case - n = 1 - , for a hashSet that lacked a function to exhibit one some element : http://tech.groups.yahoo.com/group/ocaml_beginners/message/8088 However based on the iter / exception you spoke about. Should be easy to adapt this to your problem. Regards, Fabrice