MathGroup Archive 2008

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

Search the Archive

Re: List re-arrangement question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87758] Re: [mg87733] List re-arrangement question
  • From: "Thomas Dowling" <thomasgdowling at gmail.com>
  • Date: Wed, 16 Apr 2008 06:52:32 -0400 (EDT)
  • References: <200804160904.FAA24003@smc.vnet.net>

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