# Delete many elements of a list at once [closed]

I have a list of points in 2d:

myList = {{x1,y1},... , {xn,yn}}


And a range of points I want to remove from the list, for instance:

positionsToRemove = {3,4,5,..,87,88,...,967,...}


(I am deleting the closed loops of my path.)

It looks like the delete function can only take one index at the time. Is there a way to pick the elements outside of the range given by positionsToRemove?

Something like:

myList[[~positionsToRemove]] (*returns all the points but the positions passed*)


I see how do it in Python but I am totally new to this Mathematica thing :O

• Delete[myList, List /@ positionsToRemove] should work. – C. E. Oct 26 '15 at 16:19
• Or, if you want to use Part:: myList[[Complement[Range@Length@myList, positionsToRemove]]] – eldo Oct 26 '15 at 16:28
• @Pickett you are correct, my bad. I will withdraw my comment. – e.doroskevic Oct 26 '15 at 16:45
• Delete will work, but how did you find these positions in the first place? Most of the time one would use some test, applied to each element of the list, to decide whether to remove them. If this is how you got the positions, there may be much faster ways to accomplish the deletion than this. Look up Select, Cases, DeleteCases, Pick, and take a look at this. – Szabolcs Oct 26 '15 at 17:01
• The third example under Basic Examples in the Delete documentation gives the form of Delete you are looking for. – m_goldberg Nov 2 '15 at 13:19