[erlang-questions] merging gb_trees

Joel Reymont joelr1@REDACTED
Fri Oct 21 00:56:27 CEST 2011


Forgot to mention a constraint…

Some keys may exist in one tree but not in the other.

The resulting tree should have all the keys and the values should be copied if a key does not exist in one of the tree and summed up otherwise.

I actually have multiple trees to merge into a single one but I figure I could repeat the operation two trees at a time.

On Oct 20, 2011, at 11:43 PM, Joel Reymont wrote:

> Suppose I have 2 gb_trees T1 and T2.
> 
> I want to merge them such that all the values with equal keys are summed up in the resulting tree.
> 
> What is the most elegant way to accomplish this?

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------




More information about the erlang-questions mailing list