With a list of defined matrices
list={a,b,c,d}
How can I apply Complement to obtain
Complement[list,{b,c}]=={a,d}
Answer
I guess your main confusion is that when you do
RandomSeed[1234];
list = RandomReal[1, {4, 2, 2}]
Complement[list, list[[{2, 3}]]]
then the output of the matrices is in the wrong order. The documentation of Complement
says
The list returned by Complement is sorted into standard order.
An easy trick around this is to do the complement on the indices and not on the matrices itself. After that, you can use the indices to access the matrices in list
:
list[[Complement[Range[Length[list]], {2, 3}]]]
Comments
Post a Comment