1
$\begingroup$

i have nested list as follows

x = {{x11, x12, x13}, {x21, x22, x23}, {x31, x32, x33},{x41, x42, x43}} = {{1, 3, 5}, {3, 4, 3}, {2, 6, 7}, {2, 6, 8}}

i want to make x as follow and assign it to y

y = {{x11, x21, x31, x41}, {x12, x22, x32,x42}, {x13, x23, x33,x43}} = {{1, 3, 2, 2}, {3, 4, 6, 6}, {5, 3, 7, 8}}

another question i have a list named z like this

z = {{34, {x1 -> 3, x2 -> 2}}, {12, {x1 -> 6, x2 -> 2}}, {12, {x1 -> 4, x2 -> 1}}}

and i want to assign {{x1 -> 3, x2 -> 2}, {x1 -> 6, x2 -> 2}, {x1 -> 6, x2 -> 2}} to w as follows

w= {{x1 -> 3, x2 -> 2}, {x1 -> 6, x2 -> 2}, {x1 -> 6, x2 -> 2}}
$\endgroup$
2
  • $\begingroup$ Does y=Transpose[{{x11,x12,x13},{x21,x22,x23},{x31,x32,x33},{x41,x42,x43}}] get you closer to what you want for the first question? I realize that doesn't make use of what you have already assigned to x but does the result of that give you some help? Or does y=Transpose[x] get you closer to what you want? Next look at w=Map[Last,z] for your second question $\endgroup$
    – Bill
    Sep 1 at 12:37
  • $\begingroup$ Second question. Should it be: {{x1 -> 3, x2 -> 2}, {x1 -> 6, x2 -> 2}, {x1 -> 4, x2 -> 1}}? This you can get by: z[[All, 2]] $\endgroup$ Sep 2 at 7:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.