hashtable_update(ht, key, fn, default)
Apply the function f
to the value associated with key
in the hash table ht
,
or to default
if no value is associated with key
. If fn
returns, key
is
associated with the value returned by fn
, replacing the old association.
Key
should be of an appropriate type for the hash and equivalence functions used by the hash table.
The function fn
should accept one argument, should return one value, and should not modify the hash table.
Hashtable_update
return void
.
let ht = #{1:2, 3:4}
hashtable_update(ht, 1, ^(x) x * 100)
ht
// #{1: 200, 3: 4}
hashtable_update(ht, 5, ^(x) x * 100, 6)
ht
// #{5: 600, 1: 200, 3: 4}