(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} }
Apply
? $\endgroup$Subtract @@@ pairsOfPositions
give the output you want? If so you just need to take the time to understandApply
. If this is not the result you want or you chose a narrow example please edit the question to explain. $\endgroup$