Version française
Home     About     Download     Resources     Contact us    
Browse thread
modifying hash tables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Zheng Li <li@p...>
Subject: Re: modifying hash tables
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