This function dynamically builds an object, like the {| |} syntax, except that it does not throw an error upon pair collision. Instead, it accumulates them, wrapping into an array if necessary. Non-objects are ignored.
declare function accumulate($seq as item*) as object
{
{|
keys($seq) ! { $$ : $seq.$$ }
|}
};