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



