next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: scanKeys

scanKeys -- apply a function to each key in a hash table or database

Synopsis

Description

scanKeys(t, f) applies the function f to each key in the hash table t.

i1 : t = hashTable {{1,8},{2,20},{3,4},{4,20}}

o1 = HashTable{1 => 8 }
               2 => 20
               3 => 4
               4 => 20

o1 : HashTable
i2 : scanKeys(t, print)
1
2
3
4
i3 : scanKeys(t, k -> if k>2 then print t#k)
4
20

Caveat

This function requires an immutable hash table. To scan the keys in a mutable hash table, use scan(keys t, f).

See also

Ways to use scanKeys :