On this page:
hash-union

19 Hash Tables

Sam Tobin-Hochstadt <samth@ccs.neu.edu>

 (require unstable/hash)

This library is unstable; compatibility will not be maintained. See Unstable for more information.

(hash-union t1 t2 combine)  hash?
  t1 : hash?
  t2 : hash?
  combine : (any/c any/c any/c . -> . any/c)
Produces the combination of t1 and t2. If either t1 or t2 has a value for key k, then the result has the same value for k. If both t1 and t2 have a value for k, the result has the value (combine k (hash-ref t1 k) (hash-ref t2 k)) for k.

Examples:

  > (hash-union #hash((a . 5) (b . 0)) #hash((d . 12) (c . 1)) (lambda (k v1 v2) v1))

  '#hash((b . 0) (a . 5) (d . 12) (c . 1))

  > (hash-union #hash((a . 5) (b . 0)) #hash((a . 12) (c . 1)) (lambda (k v1 v2) v1))

  '#hash((b . 0) (a . 5) (c . 1))