How do I use drop to drop the second element from all these sublists? [duplicate]












4















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}}











share|improve this question









New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard list-manipulation
Users with the  list-manipulation badge can single-handedly close list-manipulation questions as duplicates and reopen them as needed.

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




    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




    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
















4















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}}











share|improve this question









New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard list-manipulation
Users with the  list-manipulation badge can single-handedly close list-manipulation questions as duplicates and reopen them as needed.

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




    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




    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














4












4








4








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}}











share|improve this question









New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Glorfindel

2011311




2011311






New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









user62264user62264

211




211




New contributor




user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user62264 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by Lukas Lang, José Antonio Díaz Navas, Henrik Schumacher, Mr.Wizard list-manipulation
Users with the  list-manipulation badge can single-handedly close list-manipulation questions as duplicates and reopen them as needed.

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 list-manipulation
Users with the  list-manipulation badge can single-handedly close list-manipulation questions as duplicates and reopen them as needed.

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




    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




    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














  • 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








  • 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










  • 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










3 Answers
3






active

oldest

votes


















5














lst = {{1, 2}, {2, 3}, {5, 4}};

Drop[lst, None, {2}]



{{1}, {2}, {5}}







share|improve this answer





























    2














    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}}





    share|improve this answer





























      0














      Also,



      Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]





      share|improve this answer




























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        lst = {{1, 2}, {2, 3}, {5, 4}};

        Drop[lst, None, {2}]



        {{1}, {2}, {5}}







        share|improve this answer


























          5














          lst = {{1, 2}, {2, 3}, {5, 4}};

          Drop[lst, None, {2}]



          {{1}, {2}, {5}}







          share|improve this answer
























            5












            5








            5






            lst = {{1, 2}, {2, 3}, {5, 4}};

            Drop[lst, None, {2}]



            {{1}, {2}, {5}}







            share|improve this answer












            lst = {{1, 2}, {2, 3}, {5, 4}};

            Drop[lst, None, {2}]



            {{1}, {2}, {5}}








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            kglrkglr

            178k9198409




            178k9198409























                2














                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}}





                share|improve this answer


























                  2














                  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}}





                  share|improve this answer
























                    2












                    2








                    2






                    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}}





                    share|improve this answer












                    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}}






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered yesterday









                    TitusTitus

                    615417




                    615417























                        0














                        Also,



                        Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]





                        share|improve this answer


























                          0














                          Also,



                          Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]





                          share|improve this answer
























                            0












                            0








                            0






                            Also,



                            Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]





                            share|improve this answer












                            Also,



                            Drop[{{1, 2}, {2, 3}, {5, 4}}, None, -1]






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            m_goldbergm_goldberg

                            84.5k872196




                            84.5k872196















                                Popular posts from this blog

                                1300-talet

                                1300-talet

                                Display a custom attribute below product name in the front-end Magento 1.9.3.8