caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Zheng Li <li@pps.jussieu.fr>
To: caml-list@inria.fr
Subject: Re: modifying hash tables
Date: Wed, 18 Jul 2007 18:38:46 +0200	[thread overview]
Message-ID: <87ps2p7jl5.fsf@pps.jussieu.fr> (raw)
In-Reply-To: <469E3171.7040205@gnu.org>

Sam Steingold <sds@gnu.org> 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


  parent reply	other threads:[~2007-07-18 16:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 15:27 Sam Steingold
2007-07-18 16:00 ` [Caml-list] " Christopher L Conway
2007-07-18 16:01 ` Sam Steingold
2007-07-18 16:36   ` [Caml-list] " Brian Hurt
2007-07-18 16:08 ` [Caml-list] " David Allsopp
2007-07-18 16:38 ` Zheng Li [this message]
2007-07-18 20:38 ` Jon Harrop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ps2p7jl5.fsf@pps.jussieu.fr \
    --to=li@pps.jussieu.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).