I have lists created by other processing steps, which are basically constituted by elements like this:
{a, b, c, {d,e,f}, g, h} (*this is the typical element in the first list*)
and
{a, b, c, {d,e,f}, i, l} (*this one of the second*)
What I'd like to do to is: for each element in the first list, each time that a,b,c,{d,e,f} are the same, join the elements and obtain a list of elements like:
{a, b, c, {d,e,f}, g, h, i, l}.
a,b,c,{d,e,f} are guaranteed to be in the same position, but of course they vary in value and order, hence the matching.
Any ideas?
Additionally, it would be great to do this in a "fast and efficient" way, since the lists I'll deal with will be rather long.
Thanks!
EDIT: to make the question clearer.
list1= {{a,b,c,{d,e,f},10,21},{m,n,p,{r,s,t},14,64}}
list2= {{m,n,p,{r,s,t},12},{a,b,c,{d,e,f},16}}
I would like to obtain:
{{a,b,c,{d,e,f},10,21,16},{m,n,p,{r,s,t},14,64,12}}
Thanks!
a,b,c...are the same? Or do you want to search and gather from just a single list? – rm -rf May 05 '13 at 14:57{a, b, c, g, {d,e,f}, h}– Dr. belisarius May 05 '13 at 14:59A = {{a, b, c, {d,e,f}, g, h}, {l, m, n, {o,p,q}, r, s}, {u, v, w, {x,y,z}, a, b}}and listB = {{a, b, c, {d,e,f}, i, j}, {u, v, w, {x,y,z}, d, e}, {a, b, c, {d,e,f}, k, l}, {q, r, s, {o,p,q}, u, v}}— Now, do you want the{a,b,c...inAto be combined only with the first{a,b,c...inB(same position) or with both instances inB? What to do with elements that don't match (e.g.{q,r,s...inB)? Discard them or include them as is? – rm -rf May 05 '13 at 15:17