MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List re-arrangement question


Hello,

There are probably better ways, but the following is one solution:

orig = {{{a1, a2, a3}, {b1, b2, b3}}, {{a1}, {b1}}, {{a1, a2,
    a3}, {b1, b2, b3}}}


Transpose[{Flatten[orig[[All, 1]]], Flatten[orig[[All, 2]]]}]


Out[452]=   {{a1, b1}, {a2, b2}, {a3, b3}, {a1, b1}, {a1, b1}, {a2, b2},
{a3, b3}}


MapThread[List, {Flatten[orig[[All, 1]]], Flatten[orig[[All, 2]]]}]

is a slight variant.

And of course

TableForm[orig] gives a nice table of what is needed

Tom Dowling



On Wed, Apr 16, 2008 at 10:04 AM, Yaroslav Bulatov <yaroslavvb at gmail.com>
wrote:

> I'm trying to do something like the following:
> Transpose[{{{a1, a2, a3}, {a1}, {a1, a2, a3}}, {{b1, b2, b3}, {b1},
> {b1, b2, b3}}}, {3, 1, 2}]
>
> expecting to get:
> {{{a1, b1}, {a2, b2}, {a3, b3}}, {{a1, b1}}, {{a1, b1}, {a2, b2}, {a3,
> b3}}}
>
> However, it looks like Transpose doesn't work with "ragged"
> arrays...so what is the recommended Mathematica style to do the above
> transformation?
>
>


  • Prev by Date: Re: Select from list
  • Next by Date: Extending Integrate[]
  • Previous by thread: List re-arrangement question
  • Next by thread: Re: List re-arrangement question