more flexible merge function, taking the whole input array; use --harmony Map natively