Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » hash tables » mapping over hash tables » scanKeys
next | previous | forward | backward | up | index | toc

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

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:

  • scanKeys(Database,Function)
  • scanKeys(HashTable,Function)

For the programmer

The object scanKeys is a method function.


The source of this document is in Macaulay2Doc/ov_hashtables.m2:575:0.