title: Python: map four arrays
body: <p>What I want to do is somehow map two 2D arrays.
  I have two pairs of corresponding arrays:</p>
  
  <pre><code>x1=[1,2,3,4,5]
  y1=[7,9,10,17,4]
  
  x2=[3,4,5,6,7]
  y2=[5,4,1,13,12]
  </code></pre>
  
  <p>What I would like my program to do is:</p>
  
  <p>Step 1. compare x1 with x2 and find matching elements</p>
  
  <pre><code>[3,4,5]
  </code></pre>
  
  <p>Step 2. For those matching elements perform a substraction of matching y-elements:</p>
  
  <p><code>[y1(x)-y2(x)]=[y1(3)-y2(3), y1(4)-y2(4), y1(5)-y2(5)]</code></p>
  
  <p>which is the same as:
  <code>[10-5, 17-4, 4-1]=[5,13,3]</code></p>
  
  <p>Step 3. Return another two arrays, that has unused elements from x1, y1, x2, y2 and those after substraction. Expected result:</p>
  
  <p><code>x = [1,2,3,4,5,6,7]
  y = [7,9,5,13,3,13,12]</code></p>
  
  <p>Is there an easy way to do something like that, maybe using map()? Those are all separate arrays.</p>