5
$\begingroup$

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

$\endgroup$
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 '19 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 '19 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 '19 at 14:40
6
$\begingroup$
lst = {{1, 2}, {2, 3}, {5, 4}};

Drop[lst, None, {2}]

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

$\endgroup$
3
$\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}}
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.