# Mapping Part to a List [closed]

I have a list, x, where each member is itself a list of 2 coordinate points. Sometimes a member is a list of only 1 point, sometimes it is a list of more points. Note that the last member below is a list of 2 points:

x = {{{2, 1}}, {{3, 1}}, {{2, 2}}, {{5, 1}}, {{2, 1}, {3, 1}}}


For each member of the list, I want a list of the second coordinate, so that my desired output is this:

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


Normally, I would use Part. In fact, Part works if I apply it to each member individually:

In:= {{2,1}}[[All,2]]
Out= {1}

In:= {{2,1},{3,1}}[[All,2]]
Out= {1,1}


However I don't know how to map Part to each member of the list. It looks like I can only use "All" in the bracket input of Part so I wouldn't be able to use it in a Map input. How do I map [[All,2]] to each member of x?

Thanks

• Just x[[All, All, 2]] Commented Jun 16, 2022 at 22:12

x[[All, All, 2]]


Thank you!

• This is not an answer and must be deleted. Commented Jun 16, 2022 at 23:52
• I have edited the answer to show the pertinent information from the comments. If you still feel editing was never an option, and it still "must be deleted" then so be it. Commented Jun 17, 2022 at 0:20

Using Map:

Map[Last /@ # &, x]


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

• Map has a third argument that lets you specify the level at which the function shall be applied: in this case, Map[Last, x, {2}] Commented Jun 17, 2022 at 6:13