0
$\begingroup$

I want to split this table (list/array)

fulltab={{{4,2},{7,0},{8,0},{9,0},{10,0},{11,0}},{{4,5},{10,0},{11,0},{12,0},{13,0},{14,0}},{{4,8},{10,3},{14,0},{15,0},{16,0},{17,0}},{{4,11},{10,6},{16,1},{18,0},{19,0},{20,0}},{{4,14},{10,9},{16,4},{21,0},{22,0},{23,0}},{{4,17},{10,12},{16,7},{23,1},{25,0},{26,0}},{{4,20},{10,15},{16,10},{23,4},{28,0},{29,0}}}

into

r={{4,7,8,9,10,11},{4,10,11,12,13,14},{4,10,14,15,16,17},{4,10,16,18,19,20},{4,10,16,21,22,23},{4,10,16,23,25,26},{4,10,16,23,28,29}}

and

d={{2,0,0,0,0,0},{5,0,0,0,0,0},{8,3,0,0,0,0},{11,6,1,0,0,0},{14,9,4,0,0,0},{17,12,7,1,0,0},{20,15,10,4,0,0}}

What's the most efficient way to achieve this?

Thanks.

$\endgroup$
4
  • 1
    $\begingroup$ r = fulltab[[All, All, 1]] $\endgroup$
    – Kuba
    Commented Jan 8, 2015 at 22:46
  • 1
    $\begingroup$ {r, d} = Transpose[fulltab, {2, 3, 1}] $\endgroup$ Commented Jan 8, 2015 at 22:50
  • $\begingroup$ @DumpsterDoofus Thanks! That's so easy! $\endgroup$ Commented Jan 8, 2015 at 23:14
  • $\begingroup$ @Kuba Thank you, too. $\endgroup$ Commented Jan 8, 2015 at 23:14

1 Answer 1

5
$\begingroup$

You can use Transpose:

{r, d} = Transpose[fulltab, {2, 3, 1}]
$\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.