I have a list of the form:
toy = {{a, {b, c}}, {d, {e, f}}, {g, {h, j}}, {k, {m, n}}};
and would like to create the list
{{a, c}, {d, f}, {g, j}, {k, n}}
from toy.
The following code does it but I find this esthetically unsatisfactory because I don't like creating the two independent lists toy[[;; , 1]] and toy[[;; , 2, 2]] and combining them.
Transpose[{toy[[;; , 1]], toy[[;; , 2, 2]]}]
Is there a cleaner more direct way to do this?
{#[[1]], #[[2, 2]]} & /@ toyor{#1, #2[[2]]} & @@@ toy– Dr. belisarius Jan 27 '15 at 04:49toy /. {x_, {y_, z_}} :> {x, z}– BoLe Jan 27 '15 at 04:50toy[[All, 2]] = toy[[All, 2, 2]]; toy– Mike Honeychurch Jan 27 '15 at 04:56Transpose@{toy[[All,1]],toy[[All,2,2]]}– tchronis Jan 27 '15 at 07:21