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.0 required=5.0 tests=AWL,SPF_FAIL 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 BA941BC69 for ; Wed, 18 Jul 2007 18:37:33 +0200 (CEST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6IGbWJS029435 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 18 Jul 2007 18:37:33 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IBCWk-0005fe-9B for caml-list@inria.fr; Wed, 18 Jul 2007 18:37:26 +0200 Received: from ivr94-8-88-162-26-239.fbx.proxad.net ([88.162.26.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 Jul 2007 18:37:26 +0200 Received: from li by ivr94-8-88-162-26-239.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 18 Jul 2007 18:37:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: modifying hash tables Date: Wed, 18 Jul 2007 18:38:46 +0200 Message-ID: <87ps2p7jl5.fsf@pps.jussieu.fr> References: <469E3171.7040205@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ivr94-8-88-162-26-239.fbx.proxad.net User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:+sCl/XLpv3Mo8se5sKzcc1dtJxc= Sender: news X-Miltered: at concorde with ID 469E41CC.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; hash:01 hashtable:01 iter:01 hashtable:01 iter:01 pps:01 pps:01 jussieu:01 jussieu:01 writes:01 semantic:02 data:02 data:02 modifying:02 binding:02 Sam Steingold writes: > 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)) If you have associate several datums with the same key, the semantic of the code is to substitute the current binding of each key with the value of its earliest binding plus one. -- Zheng Li http://www.pps.jussieu.fr/~li