scanPairs(t, f) applies the function f to each pair (k, t#k) in the hash table t. In other words, f is applied to each key k paired with its corresponding value t#k.
i1 : t = hashTable {{1,8},{2,20},{3,4},{4,20}} o1 = HashTable{1 => 8 } 2 => 20 3 => 4 4 => 20 o1 : HashTable |
i2 : scanPairs(t, (k,v) -> print (k+v)) 9 22 7 24 |
i3 : scanPairs(t, (k,v) -> if v==20 then print k) 2 4 |
This function requires an immutable hash table. To scan the pairs in a mutable hash table, use scan(pairs t, f).
The object scanPairs is a compiled function.