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=1.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 69AFDBC6B for ; Tue, 11 Dec 2007 17:36:26 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CALZLXkdQDPIThWdsb2JhbACBWohBhU4BAQEIBAYPEwc X-IronPort-AV: E=Sophos;i="4.24,153,1196636400"; d="scan'208";a="20212247" Received: from smtp19.orange.fr ([80.12.242.19]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Dec 2007 17:36:26 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf1929.orange.fr (SMTP Server) with ESMTP id 80BB11C000A2 for ; Tue, 11 Dec 2007 17:36:25 +0100 (CET) Received: from localhost.localdomain (Mix-Lyon-303-3-34.w193-248.abo.wanadoo.fr [193.248.105.34]) by mwinf1929.orange.fr (SMTP Server) with ESMTP id 9105F1C0008E for ; Tue, 11 Dec 2007 17:36:24 +0100 (CET) X-ME-UUID: 20071211163624594.9105F1C0008E@mwinf1929.orange.fr Date: Tue, 11 Dec 2007 16:40:11 +0100 From: Fabrice Marchant To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Hashtbl: get first n keys Message-ID: <20071211164011.16469000@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) 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 Based on the iter / exception however. Should be easy to adapt this to your problem. Regards, Fabrice