# I keep writing functions like this one: subtract[{a_, b_}] := Subtract[a, b] [duplicate]

(Edited to provide an example)

Recently I have found myself writing silly functions like the following, which is just a new arity of Subtract in which the arguments are inside a list.

subtract[{a_, b_}] := Subtract[a, b]

If I were adding that variant to one of my own functions, I would use the same name, and would feel more comfortable about it.

I feel sure I should not need to do this for system functions, yet these variants are very convenient when I am working with lists.

There is probably some elementary principle of Mathematica coding that I have failed to absorb. What could it be?

Example:

pairsOfPositions = {{{a, b, c}, {d, e, f}}, {{g, h, i}, {j, k, l}}, {{m, n, o}, {p, q, r}}}; differences = Map[subtract, pairsOfPositions, {1}];

where the desired result for differences is  { {a - d, b - e, c - f}, {g - j, h - k, i - l}, {m - p, n - q, o - r} }

## marked as duplicate by Jens, kale, Mr.Wizard♦Aug 3 '15 at 2:31

• @RalphDratman does not Subtract @@@ pairsOfPositions give the output you want? If so you just need to take the time to understand Apply. If this is not the result you want or you chose a narrow example please edit the question to explain. – Mr.Wizard Aug 3 '15 at 2:30
Subtract @@ {a, b}