4
$\begingroup$

Another newbie question. I'm trying to figure out how to produce rr given dd and hh:

dd = {{{a, b}, {c, d}}, {{e, f}, {g, h}}};
hh = {x, y};
rr = {{{x, x}, {y, y}}, {{a, b}, {c, d}}, {{e, f}, {g, h}}};

{Grid[dd, Frame -> All], Grid[{hh}, Frame -> All], Grid[rr, Frame -> All]}
$\endgroup$

1 Answer 1

4
$\begingroup$
Join[{{#, #} & /@ hh}, dd]

{{{x, x}, {y, y}}, {{a, b}, {c, d}}, {{e, f}, {g, h}}}

Also:

Join[{Transpose[{hh, hh}]}, dd]

{{{x, x}, {y, y}}, {{a, b}, {c, d}}, {{e, f}, {g, h}}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.