, , .
Here is my attempt and, as a structural more functional programmer, I used the table [] (OMG!) To do this. Well, table [] is still on the verge of functional programming :)
(Here A is data2, and B is data1)
n=Length[A]; m=Length[B];
isMatch[a_,b_] := a[[1]]=== b[[1]]&&a[[2]]===b[[2]]
A[[1]] = A[[1]]~Join~B[[1,3;;-1]]; (*do the header on its own*)
Table[If[ isMatch[B[[i]],A[[j]]],
A[[j]] = Join[A[[j]],B[[i,3;;-1]]]
],
{i,2,m},{j,2,n}
];
A
- Nasser
source
share