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












4












$begingroup$



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











$endgroup$



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();
}
);
});
});
Jan 9 at 0:56


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




    $begingroup$
    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
    $endgroup$
    – Lukas Lang
    Jan 8 at 12:19








  • 2




    $begingroup$
    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.
    $endgroup$
    – Sjoerd Smit
    Jan 8 at 14:06










  • $begingroup$
    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!
    $endgroup$
    – Chris K
    Jan 8 at 14:40
















4












$begingroup$



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











$endgroup$



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();
}
);
});
});
Jan 9 at 0:56


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




    $begingroup$
    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
    $endgroup$
    – Lukas Lang
    Jan 8 at 12:19








  • 2




    $begingroup$
    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.
    $endgroup$
    – Sjoerd Smit
    Jan 8 at 14:06










  • $begingroup$
    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!
    $endgroup$
    – Chris K
    Jan 8 at 14:40














4












4








4





$begingroup$



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











$endgroup$





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















share|improve this question













share|improve this question




share|improve this question








edited Jan 8 at 14:24









Glorfindel

2191311




2191311










asked Jan 8 at 12:10









user62264user62264

211




211




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();
}
);
});
});
Jan 9 at 0:56


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();
}
);
});
});
Jan 9 at 0:56


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




    $begingroup$
    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
    $endgroup$
    – Lukas Lang
    Jan 8 at 12:19








  • 2




    $begingroup$
    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.
    $endgroup$
    – Sjoerd Smit
    Jan 8 at 14:06










  • $begingroup$
    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!
    $endgroup$
    – Chris K
    Jan 8 at 14:40














  • 3




    $begingroup$
    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
    $endgroup$
    – Lukas Lang
    Jan 8 at 12:19








  • 2




    $begingroup$
    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.
    $endgroup$
    – Sjoerd Smit
    Jan 8 at 14:06










  • $begingroup$
    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!
    $endgroup$
    – Chris K
    Jan 8 at 14:40








3




3




$begingroup$
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
$endgroup$
– Lukas Lang
Jan 8 at 12:19






$begingroup$
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
$endgroup$
– Lukas Lang
Jan 8 at 12:19






2




2




$begingroup$
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.
$endgroup$
– Sjoerd Smit
Jan 8 at 14:06




$begingroup$
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.
$endgroup$
– Sjoerd Smit
Jan 8 at 14:06












$begingroup$
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!
$endgroup$
– Chris K
Jan 8 at 14:40




$begingroup$
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!
$endgroup$
– Chris K
Jan 8 at 14:40










3 Answers
3






active

oldest

votes


















5












$begingroup$

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

Drop[lst, None, {2}]



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







share|improve this answer









$endgroup$





















    2












    $begingroup$

    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









    $endgroup$





















      0












      $begingroup$

      Also,



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





      share|improve this answer









      $endgroup$




















        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5












        $begingroup$

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

        Drop[lst, None, {2}]



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







        share|improve this answer









        $endgroup$


















          5












          $begingroup$

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

          Drop[lst, None, {2}]



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







          share|improve this answer









          $endgroup$
















            5












            5








            5





            $begingroup$

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

            Drop[lst, None, {2}]



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







            share|improve this answer









            $endgroup$



            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 Jan 8 at 12:34









            kglrkglr

            180k9200413




            180k9200413























                2












                $begingroup$

                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









                $endgroup$


















                  2












                  $begingroup$

                  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









                  $endgroup$
















                    2












                    2








                    2





                    $begingroup$

                    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









                    $endgroup$



                    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 Jan 8 at 12:24









                    TitusTitus

                    645417




                    645417























                        0












                        $begingroup$

                        Also,



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





                        share|improve this answer









                        $endgroup$


















                          0












                          $begingroup$

                          Also,



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





                          share|improve this answer









                          $endgroup$
















                            0












                            0








                            0





                            $begingroup$

                            Also,



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





                            share|improve this answer









                            $endgroup$



                            Also,



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






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 8 at 19:52









                            m_goldbergm_goldberg

                            85.1k872196




                            85.1k872196















                                Popular posts from this blog

                                Probability when a professor distributes a quiz and homework assignment to a class of n students.

                                Aardman Animations

                                Are they similar matrix