{{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}}
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communitylst = {{1, 2}, {2, 3}, {5, 4}};
Drop[lst, None, {2}]
{{1}, {2}, {5}}
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}}
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 $\endgroup$Delete
, notDrop
.Drop
is the opposite ofTake
. $\endgroup$