How to drop certain elements in certain positions from a list using drop function

Clash Royale CLAN TAG#URR8PPP

a = Table[i, {i, 1, 10}]
Drop[a, {5, 8}]


If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which are a position 5 and position 8 using drop function.

a = Table[i, {i, 1, 10}]
Drop[a, {5, 8}]


If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which are a position 5 and position 8 using drop function.

a = Table[i, {i, 1, 10}]
Drop[a, {5, 8}]


If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which are a position 5 and position 8 using drop function.

a = Table[i, {i, 1, 10}]
Drop[a, {5, 8}]


If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which are a position 5 and position 8 using drop function.

list-manipulation matrix

acoustics

32118

32118

active

oldest

Use instead Delete, in this way:

a = Table[i, {i, 1, 10}];
Delete[a, {{5}, {8}}]


(*

{1, 2, 3, 4, 6, 7, 9, 10}

*)

By the way, you can be far more efficient:

a = Range[10]


• can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

• Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

• Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

Drop[a, {5, 8, 3}]


{1, 2, 3, 4, 6, 7, 9, 10}

Fold[Drop[#, {#2}] &, a, Reverse[{5, 8}]]


{1, 2, 3, 4, 6, 7, 9, 10}

active

oldest

active

oldest

active

oldest

active

oldest

Use instead Delete, in this way:

a = Table[i, {i, 1, 10}];
Delete[a, {{5}, {8}}]


(*

{1, 2, 3, 4, 6, 7, 9, 10}

*)

By the way, you can be far more efficient:

a = Range[10]


• can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

• Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

• Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

Use instead Delete, in this way:

a = Table[i, {i, 1, 10}];
Delete[a, {{5}, {8}}]


(*

{1, 2, 3, 4, 6, 7, 9, 10}

*)

By the way, you can be far more efficient:

a = Range[10]


• can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

• Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

• Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

Use instead Delete, in this way:

a = Table[i, {i, 1, 10}];
Delete[a, {{5}, {8}}]


(*

{1, 2, 3, 4, 6, 7, 9, 10}

*)

By the way, you can be far more efficient:

a = Range[10]


Use instead Delete, in this way:

a = Table[i, {i, 1, 10}];
Delete[a, {{5}, {8}}]


(*

{1, 2, 3, 4, 6, 7, 9, 10}

*)

By the way, you can be far more efficient:

a = Range[10]


David G. Stork

22.7k22051

22.7k22051

• can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

• Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

• Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

• can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

• Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

• Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

can we give the list of position which I wanted to drop like {3,5,8,9}
– acoustics
Nov 29 at 7:49

2

Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

Delete[a,{{3},{5},{8},{9}}]
– David G. Stork
Nov 29 at 7:50

1

Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

Also Delete[a, Partition[{3, 5, 8, 9}, 1]] comes to mind… if the list of positions gets longer.
– Henrik Schumacher
Nov 29 at 8:04

Drop[a, {5, 8, 3}]


{1, 2, 3, 4, 6, 7, 9, 10}

Fold[Drop[#, {#2}] &, a, Reverse[{5, 8}]]


{1, 2, 3, 4, 6, 7, 9, 10}

Drop[a, {5, 8, 3}]


{1, 2, 3, 4, 6, 7, 9, 10}

Fold[Drop[#, {#2}] &, a, Reverse[{5, 8}]]


{1, 2, 3, 4, 6, 7, 9, 10}

Drop[a, {5, 8, 3}]


{1, 2, 3, 4, 6, 7, 9, 10}

Fold[Drop[#, {#2}] &, a, Reverse[{5, 8}]]


{1, 2, 3, 4, 6, 7, 9, 10}

Drop[a, {5, 8, 3}]


{1, 2, 3, 4, 6, 7, 9, 10}

Fold[Drop[#, {#2}] &, a, Reverse[{5, 8}]]


{1, 2, 3, 4, 6, 7, 9, 10}

edited Nov 29 at 7:49

kglr

175k9197402

175k9197402

Thanks for contributing an answer to Mathematica Stack Exchange!

But avoid

• Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

Please pay close attention to the following guidance:

But avoid

• Making statements based on opinion; back them up with references or personal experience.

draft saved

function () {
}
);

Post as a guest

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown

Required, but never shown