The solution offered by Okkes will not work if you use Apply
. the reason is that both Max and Min use only the first argument (the # sign), so if you try (@@ is the shortcut for Apply
and @@@ for Apply
at level 1)
(Max[#] - Min[#]) @@@ {{1, 2, 3}, {4, 5}, {6, 7, 8, 9}}
you will get {0,0,0}
as the answer
So, you need to take care that both Max and Min will enclose all the arguments and for that you need to use ## (SlotSequence
stand for "all arguments", see documentation). So
(Max[##] - Min[##]) & @@@ {{1, 2, 3}, {4, 5}, {6, 7, 8, 9}}
returns {2,1,3}
as expected, and probably this is what you are looking for
yehuda