3
$\begingroup$

I noticed that one can subtract a since real number value from all elements in an array by writing something like

{5, 4, 3, 2, 1} - 5

which outputs {0, -1, -2, -3, -4}. However, this doesn't seem to extend to coordinates, where we get an "objects of unequal length" error for a command like

{{5, 4}, {5, 2}, {5, 1}, {5, -5}} - {2, 2}

Is there a way to easily do make something like above work so that {2,2} is subtracted from each list item automatically?

$\endgroup$
  • $\begingroup$ Hmm, I would Map it: # - {2, 2} & /@ {{5, 4}, {5, 2}, {5, 1}, {5, -5}} (I'm not posting it as an answer because I'm looking for duplicate ;)) $\endgroup$ – Kuba Sep 8 '13 at 15:40
  • 1
    $\begingroup$ Possible duplicate: (23395) $\endgroup$ – Mr.Wizard Sep 8 '13 at 15:55

Browse other questions tagged or ask your own question.