[erlang-questions] adding maps:merge_nested/2

Michael Truog mjtruog@REDACTED
Mon Nov 14 21:20:19 CET 2016

On 11/12/2016 01:58 PM, Guilherme Andrade wrote:
> Throwing my two cents out there: I would find 'merge_nested' useful (I'm pretty sure I've had the need of something similar in the past) but it looks a bit too specific for the maps module; particularly, one can think of it as a "map of (maps of ...)" method, not simply a generic, flattened maps one.
> Then again, the lists module includes (very dearly needed) functions for dealing with 'lists of tuples', so what do I know :)
> Perhaps an alternative would be having a merge/N function that receives a custom value-merger function (besides the unmerged maps), and use it recursively to solve your particular problem.
The main merge function you are missing in the maps module, is the merge/3 (instead of merge/2) that is common in other modules (like the dict/orddict modules).  I added an implementation of merge/3 at https://github.com/okeuday/mapsd due to needing the dict API elsewhere.  With the merge/3 function it should be easier to merge nested maps, in whatever way is required, since one size shouldn't fit all.

More information about the erlang-questions mailing list