I understood the function from bairui directly (why didn't i think of that..) but i had to look in the documentation to understand cormullion's solution and then i saw in the documentation this example:
(set-ref-all '(oranges *) data (list (first $it) (apply + (rest $it))) match) ....
Great docs, just have to read them more carefully next time.