[top][index]
search for:

combine -- combine hash tables

Synopsis:

  • Usage: z = combine(x,y,f,g,h)
  • Input:
  • x: a hash table
  • y: a hash table of the same class as x
  • f: a function of two variables to be used for combining a key of x with a key of y to make a new key for z.
  • Output:
  • z: a new hash table, of the same class as x and y, containing the pair f(p,q) => g(b,c) whenever x contains the pair p => b and y contains the pair q => c, except that h is used to combine values when two keys coincide.
  • The function f is applied to every pair (p,q) where p is a key of x and q is a key of y. The number of times f is evaluated is thus the product of the number of keys in x and the number of keys in y.

    The function h should be an associative function, for otherwise the result may depend on internal details about the implementation of hash tables that affect the order in which entries are encountered. If f, g, and h are commutative functions as well, then the result z is a commutative function of x and y.

    The result is mutable if and only if x or y is.

    This function can be used for multiplying polynomials, where it can be used in code something like this:

              combine(x, y, monomialTimes, coeffTimes, coeffPlus)


    [top][index]
    search for: