next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc > The Macaulay2 language > hash tables > applyPairs

applyPairs -- apply a function to each pair in a hash table

Synopsis

Description

i1 : H = new HashTable from {1 => 10, 2 => 15, 3 => 20}

o1 = HashTable{1 => 10}
               2 => 15
               3 => 20

o1 : HashTable
i2 : applyPairs(H, (k,v) -> (k+1, v+10))

o2 = HashTable{2 => 20}
               3 => 25
               4 => 30

o2 : HashTable
i3 : applyPairs(H, (k,v) -> (v,k))

o3 = HashTable{10 => 1}
               15 => 2
               20 => 3

o3 : HashTable

Caveat

It is an error for the function f to return two pairs with the same key.

See also

Ways to use applyPairs :