Delta Formula in RM confusion

I believe the delta formula is wrong or precedence confuses me

writes the following:

delta = sum(r.delta() for r in outputResources - sum(r.delta() for r in inputResources))

I assume the following was meant?

def delta(input-resources, output-resources) =
  sum(map(delta, output-resources)) - sum(map(delta, input-resources))
(defun delta (input output)
  (- (∑ (map #'delta output) 
     (∑ (map #'delta input))))

Otherwise I’m confused for how for and - interact and how we are summing over double iterating over things (precedence often confuses my tiny brain).

Further I am also confused about input - output or output - input, as the mathematical formula looks like:

which demonstrates it’s input - output, along with a more correct calculation?