It produces a new hash table y from a hash table x by applying the function f to the pair (k,v) for each key k, where v is the value stored in x as x#k. Thus f should be a function of two variables which returns either a pair (kk,vv) which is placed into y, or it returns null, which signifies that no action be performed.
In this example, we show how to produce the hash table corresponding to the inverse of a function.
i1 : x = new HashTable from {1 => a, 2 => b, 3 => c} |
i2 : y = applyPairs(x, (k,v) -> (v,k)) |
i3 : x#2 |
i4 : y#b |
See also applyValues, applyKeys, and scanPairs.