Re: complicated list selector
- To: mathgroup at smc.vnet.net
- Subject: [mg98444] Re: [mg98415] complicated list selector
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 10 Apr 2009 04:51:13 -0400 (EDT)
- Reply-to: hanlonr at cox.net
data = {{11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}}}; data /. {x_, y_?NumericQ} :> y {{11, 122}, {21, 222}, {31, 322}} MapAt[Last, #, 2] & /@ data {{11, 122}, {21, 222}, {31, 322}} (Flatten /@ data)[[All, {1, 3}]] {{11, 122}, {21, 222}, {31, 322}} Flatten[#][[{1, 3}]] & /@ data {{11, 122}, {21, 222}, {31, 322}} Bob Hanlon ---- summer <summertan at hotmail.com> wrote: ============= I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; >From each sublist, I want to extract the first element and the second element of the second sub-sub-list that is: wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ?