Looking at that code again I think it should be rewritten to use map:for-each
it's too convoluted, but it probably gives you an idea of how to proceed.
Here's a test that shows how it works.
https://github.com/xokomola/fold/blob/dbb79c60a7356e32a0994e581ad4f7f5377ddc72/test/fold-common/test-common.xqm#L166
--Marc

On 15 jul. 2015, at 21:51, Marc van Grootel <marc.van.grootel@gmail.com> wrote:

Hi Graydon, have a look here https://github.com/xokomola/fold/blob/dbb79c60a7356e32a0994e581ad4f7f5377ddc72/webapp/fold-common/common.xqm#L125

hope it helps

--Marc

On 15 jul. 2015, at 20:01, Graydon Saunders <graydonish@gmail.com> wrote:

Hi --

In BaseX 8.2.1, I have a bunch of maps; the maps may have some overlap of key values.  I would like to merge/find the union of all of these maps while retaining all the values associated with each key in the resulting map-of-all-maps.  (Combined map?  Any word can be wrong, here! :)

map:merge() doesn't do this;  http://docs.basex.org/wiki/Map_Module#map:merge says
"The associated value for each such key is taken from the last map in the input sequence $input that contains an entry with this key." and testing confirms this.

Is there a straightforward way to do this that I'm missing?

Thanks!
Graydon