The result of
applyPairs(H,f) is a new hash table obtained by applying the function
f to each key/value pair
(k,v) in
H and storing the resulting key/value pair in the new hash table. If the function returns
null then no action is 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}
o1 = HashTable{1 => a}
2 => b
3 => c
o1 : HashTable
|
i2 : y = applyPairs(x, (k,v) -> (v,k))
o2 = HashTable{a => 1}
b => 2
c => 3
o2 : HashTable
|
i3 : x#2
o3 = b
o3 : Symbol
|
i4 : y#b
o4 = 2
|