I have a list with many elements (189)
and I want to delete certain elements from it. I have a list of elements I want deleted from it:
{3, 4, 5, 8, 9, 13, 15, 16, 19, 22, 33, 35, 38, 39, 40, 47, 48, 49,
50, 51, 52, 53, 63, 64, 78, 126, 143, 160, 167, 170, 173, 174, 179, 189}
And I want to end up with a list of 155
elements.
The Delete command seems to only work for one specified element.
My attempt is this(for a simpler list):
list = {1, 2, 3}
nonopt = {1, 3}
For[i = 1, i < 4, i++,
If[MemberQ[nonopt, i], list[[i]] = 0]]
What I'm trying to do is make all elements I want deleted equal to zero and then find out how I can delete all zero elements, but I'm getting stuck here. For some reason, list ends up being equal to {0,0,0}
despite MemberQ[nonopt,2]
evaluating to false.
If
, not 'if', and your code works. $\endgroup$