It would be nice to have a functional version of hash-table-union! with this signature:
(hash-table-union
hash-table1 hash-table2merge-proc)
Rather than mutating either input hash table, it would return a new one of the same type that contained the union of the keys. Each key would be associated with a value returned by merge-proc when given the values at that key in the input hash tables. #f would be passed as input when one hash table didn't contain that key.In fact, the imperative version should take an optional merge-proc, too, rather than just overwriting the second hash table's values. That would make it handle many more use cases.