How do I use drop to drop the second element from all these sublists? [duplicate]
This question already has an answer here:
Correct way to remove matrix columns?
3 answers
How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?
2 answers
{{1, 2}, {2, 3}, {5, 4}}
I tried to do this:
Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
but it gave
{1}
but what I want is
{{1},{2},{5}}
list-manipulation
New contributor
marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Correct way to remove matrix columns?
3 answers
How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?
2 answers
{{1, 2}, {2, 3}, {5, 4}}
I tried to do this:
Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
but it gave
{1}
but what I want is
{{1},{2},{5}}
list-manipulation
New contributor
marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
3
UseMap
(/@
) instead ofApply
(@@
).Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent toDrop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want
– Lukas Lang
yesterday
2
I'd like to add to the answers here that the correct function for dropping a single element isDelete
, notDrop
.Drop
is the opposite ofTake
.
– Sjoerd Smit
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday
add a comment |
This question already has an answer here:
Correct way to remove matrix columns?
3 answers
How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?
2 answers
{{1, 2}, {2, 3}, {5, 4}}
I tried to do this:
Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
but it gave
{1}
but what I want is
{{1},{2},{5}}
list-manipulation
New contributor
This question already has an answer here:
Correct way to remove matrix columns?
3 answers
How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?
2 answers
{{1, 2}, {2, 3}, {5, 4}}
I tried to do this:
Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
but it gave
{1}
but what I want is
{{1},{2},{5}}
This question already has an answer here:
Correct way to remove matrix columns?
3 answers
How to use “Drop” function to drop matrix' rows and columns in an arbitrary way?
2 answers
list-manipulation
list-manipulation
New contributor
New contributor
edited yesterday
Glorfindel
2011311
2011311
New contributor
asked yesterday
user62264user62264
211
211
New contributor
New contributor
marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
yesterday
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
3
UseMap
(/@
) instead ofApply
(@@
).Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent toDrop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want
– Lukas Lang
yesterday
2
I'd like to add to the answers here that the correct function for dropping a single element isDelete
, notDrop
.Drop
is the opposite ofTake
.
– Sjoerd Smit
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday
add a comment |
3
UseMap
(/@
) instead ofApply
(@@
).Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent toDrop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want
– Lukas Lang
yesterday
2
I'd like to add to the answers here that the correct function for dropping a single element isDelete
, notDrop
.Drop
is the opposite ofTake
.
– Sjoerd Smit
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday
3
3
Use
Map
(/@
) instead of Apply
(@@
). Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent to Drop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want– Lukas Lang
yesterday
Use
Map
(/@
) instead of Apply
(@@
). Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent to Drop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want– Lukas Lang
yesterday
2
2
I'd like to add to the answers here that the correct function for dropping a single element is
Delete
, not Drop
. Drop
is the opposite of Take
.– Sjoerd Smit
yesterday
I'd like to add to the answers here that the correct function for dropping a single element is
Delete
, not Drop
. Drop
is the opposite of Take
.– Sjoerd Smit
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday
add a comment |
3 Answers
3
active
oldest
votes
lst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
add a comment |
Your result is the first column of a matrix. If list={{1, 2}, {2, 3}, {5, 4}}
,
res=list[[All, 1]]
If you need the brackets around each element, Partition[res, 1]
If your lists are of unequal length, the solution from Lukas Lang is fine. I include for completeness.
Drop[#, {2}] & /@ {{1, 2}, {2, 3}, {5, 4}}
add a comment |
Also,
Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
lst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
add a comment |
lst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
add a comment |
lst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
lst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
answered yesterday
kglrkglr
178k9198409
178k9198409
add a comment |
add a comment |
Your result is the first column of a matrix. If list={{1, 2}, {2, 3}, {5, 4}}
,
res=list[[All, 1]]
If you need the brackets around each element, Partition[res, 1]
If your lists are of unequal length, the solution from Lukas Lang is fine. I include for completeness.
Drop[#, {2}] & /@ {{1, 2}, {2, 3}, {5, 4}}
add a comment |
Your result is the first column of a matrix. If list={{1, 2}, {2, 3}, {5, 4}}
,
res=list[[All, 1]]
If you need the brackets around each element, Partition[res, 1]
If your lists are of unequal length, the solution from Lukas Lang is fine. I include for completeness.
Drop[#, {2}] & /@ {{1, 2}, {2, 3}, {5, 4}}
add a comment |
Your result is the first column of a matrix. If list={{1, 2}, {2, 3}, {5, 4}}
,
res=list[[All, 1]]
If you need the brackets around each element, Partition[res, 1]
If your lists are of unequal length, the solution from Lukas Lang is fine. I include for completeness.
Drop[#, {2}] & /@ {{1, 2}, {2, 3}, {5, 4}}
Your result is the first column of a matrix. If list={{1, 2}, {2, 3}, {5, 4}}
,
res=list[[All, 1]]
If you need the brackets around each element, Partition[res, 1]
If your lists are of unequal length, the solution from Lukas Lang is fine. I include for completeness.
Drop[#, {2}] & /@ {{1, 2}, {2, 3}, {5, 4}}
answered yesterday
TitusTitus
615417
615417
add a comment |
add a comment |
Also,
Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]
add a comment |
Also,
Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]
add a comment |
Also,
Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]
Also,
Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]
answered yesterday
m_goldbergm_goldberg
84.5k872196
84.5k872196
add a comment |
add a comment |
3
Use
Map
(/@
) instead ofApply
(@@
).Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}}
is essentially equivalent toDrop[{1, 2}, {2, 3}, {5, 4}, {2}]
, which is clearly not what you want– Lukas Lang
yesterday
2
I'd like to add to the answers here that the correct function for dropping a single element is
Delete
, notDrop
.Drop
is the opposite ofTake
.– Sjoerd Smit
yesterday
Welcome to Mathematica.SE user62264! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Chris K
yesterday