I have a list with contains entries that are length 8 sublists,i.e.
L1={{a1,b1,c1,d1,A1,B1,C1,D1},{a2,b2,c2,d2,A2,B2,C2,D2},...}
and so on.
Now, in my problem two sublists are identical if the product of the first 4 entries of two sublists is identical. In this case I want to throw one of them out. My try at this was as follows:
Do[If[Product[L1[[i]][[k]], {k, 1, 4}] == Product[L1[[j]][[m]], {m, 1, 4}],
Delete[L1,j], {i, 1, Length[L1]}, {j, i + 1, Length[L1]}];
but this doesn't work because in this way I'm changing L1
while I'm working with it. How can I improve my code / make it right? I don't see it right now...Thanks!
DeleteDuplicates
, using the 2nd argument (test
). There is a nice example you might want to apply/adapt in theScope
section in the documentation center. $\endgroup$Delete[L1,j]
does not do anything. Notice thatL1=Delete[L1,j]
is not a fix, you will get lost with indices. Maybe tryL1[[j]]=""
and at the endL1=L1/.""->Sequence[]
. Just for sport because you should use something built in, likeDeleteDuplicates
/ $\endgroup$L1
(and the wanted result) for ease of testing. $\endgroup$