[top][index]
search for:

applyKeys -- apply a function to each key in a hash table

applyKeys(x,f) -- applies f to each key k in the hash table x to produce a new hash table.

Thus f should be a function of one variable k which returns a new key k' for the value v in y.

It is an error for the function f to return the same key twice.

i1 : x = new HashTable from {1 => a, 2 => b, 3 => c}

o1 = HashTable{1 => a}
               2 => b
               3 => c

o1 : HashTable
i2 : applyKeys(x, k -> k + 100)

o2 = HashTable{101 => a}
               102 => b
               103 => c

o2 : HashTable

See also:

  • applyValues -- apply a function to each value
  • applyPairs -- apply a function to pairs in a hash table
  • Ways to use applyKeys :

  • applyKeys(HashTable,Function)

  • [top][index]
    search for: