I am trying to increase the level of nesting in the following list while adding a 'tag' to each leaf:
testd = {{59.15, 13.2, 13.52, 0.7}, {77.21, 12.27, 0.12, 0.01},
{77.25, 12.35, 1.01, 0.02}, {78.22, 11.74, 1.26, 0.01},
{79.26, 11.37, 1.03, 0.02}};
tag = {a, b, c, d}
So, the end product would look like
(* {{{a, 59.15},{b, 13.2},{c, 13.52},{d, 0.7}},
{{a, 77.21},{b, 12.27},{c, 0.12},{d, 0.01}},
<< ... >>
{{a, 79.26},{b, 11.37},{c, 1.03},{d, 0.02}}} *)
I can use
Replace[testd, x_ -> {x}, {2}]
to get
(* {{{59.15},{13.2},{13.52},{0.7}},{{77.21},{12.27},{0.12},{<0.01}},
{{77.25},{12.35},{1.01},{0.02}},{{78.22},{11.74},{1.26},{0.01}},
{{79.26},{11.37},{1.03},{0.02}}} *)
I have tried
Replace[testd, x_ -> {#, x}, {2}] & /@ tag
{{{{a, b, c, d}, 59.15}, {{a, b, c, d}, 13.2}, {{a, b, c, d}, 13.52}, {{a, b, c, d}, 0.7}}, {{{a, b, c, d}, 77.21}, {{a, b, c, d}, 12.27}, {{a, b, c, d}, 0.12}, {{a, b, c, d}, "<0.01"}}, {{{a, b, c, d}, 77.25}, {{a, b, c, d}, 12.35}, {{a, b, c, d}, 1.01}, {{a, b, c, d}, 0.02}}, {{{a, b, c, d}, 78.22}, {{a, b, c, d}, 11.74}, {{a, b, c, d}, 1.26}, {{a, b, c, d}, 0.01}}, {{{a, b, c, d}, 79.26}, {{a, b, c, d}, 11.37}, {{a, b, c, d}, 1.03}, {{a, b, c, d}, 0.02}}}
which is not what i want...
Can someone help me with the right syntax? or suggest a better way?
Rifflesolution to the other question..? – geordie Aug 29 '13 at 09:11Rifflesolution is nice, on the other hand rm-rf usesMapeverywhere. I'm sure myInnersolution is the most efficient. – Artes Aug 29 '13 at 11:04