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,MISSING_HEADERS, SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 84774BC69 for ; Wed, 18 Jul 2007 18:01:51 +0200 (CEST) Received: from smtp.janestcapital.com (www.janestcapital.com [66.155.124.107]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6IG1oeV019508 for ; Wed, 18 Jul 2007 18:01:51 +0200 Received: from [172.25.131.105] [38.96.172.125] by janestcapital.com with ESMTP (SMTPD-9.10) id A982040C; Wed, 18 Jul 2007 12:02:10 -0400 Message-ID: <469E396D.7010508@gnu.org> Date: Wed, 18 Jul 2007 12:01:49 -0400 From: Sam Steingold User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 Cc: Caml List Subject: Re: modifying hash tables References: <469E3171.7040205@gnu.org> In-Reply-To: <469E3171.7040205@gnu.org> X-Enigmail-Version: 0.95.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 469E396E.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hash:01 hash:01 hashtable:01 iter:01 hashtable:01 iter:01 ocaml:01 wrote:01 lisp:01 lisp:01 data:02 data:02 modifying:02 traversal:03 traversal:03 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Sam Steingold wrote: > I want to modify the _current_ datum in Hashtable.iter, e.g., increment > a count. Is this code valid? > Hashtable.iter ht ~f:(fun ~key ~data -> > Hashtable.replace ht ~key ~data:(data+1)) > (it appears to work, but I was told that "it is not guaranteed to work", > i.e., the documentation does not promise that). > If the above code is wrong, what is TRT? in case you wondered why I think my code is reasonable: http://www.lisp.org/HyperSpec/Body/sec_3-6.html Hash-table traversal For hash table traversal operations, new elements may not be added or deleted except that the element corresponding to the current hash key may be changed or removed. (yes, I know OCaml is NOT Common Lisp). -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGnjltPp1Qsf2qnMcRAhZDAJ9JLNLklo6tK+oGSd2ije172z+3+wCcDXyc JRU8vSR/5cMBDeBTFjvSylg= =Q5wE -----END PGP SIGNATURE-----