Re: List manipulation

• To: mathgroup at smc.vnet.net
• Subject: [mg70206] Re: List manipulation
• From: Peter Pein <petsie at dordos.net>
• Date: Sat, 7 Oct 2006 07:08:00 -0400 (EDT)
• References: <eg4rtn\$fah\$1@smc.vnet.net>

```xun schrieb:
> Hello,
>
> I have something as following:
>
> a = Array[aa, {3, 3}];
> b = Array[bb, {3, 3}];
> c = Array[cc, {3, 3}];
> d = Array[dd, {3, 3}];
> A = {{a, b}, {c, d}} (* A consists of four blocks *)
> A // MatrixForm
>
> And I want a 6*6 matrix (a list of 6 lists) just as A looks like.
> For example, the first row should be
>
> aa[1,1],aa[1,2],aa[1,3],bb[1,1],bb[1,2],bb[1,3]
>
> etc....
>
> How to get it easily?
>
> Many thanks.
> Xun
>
>

Hi Xun,

This:
Transpose[Flatten[Thread[Join[##]] & @@@ {{a, c}, {b, d}}, 1]]
or this:
Join @@@ Flatten[Thread[List[##]] & @@@ {{a, b}, {c, d}}, 1]
or this:
Sequence @@@ Map[Flatten, Thread[{##}] & @@@ {{a, b}, {c, d}}, {2}]
and for sure dozens of other (propably more efficient) methods do what
you want.

Easy to remember is:

<< Statistics`DataManipulation`
ColumnJoin[RowJoin[a, b], RowJoin[c, d]]
or if you prefer to write all parameters at the end:
ColumnJoin @@ RowJoin @@@ {{a, b}, {c, d}}

HTH,
Peter

```

• Prev by Date: Re: FoourierTransform of a function defined in sections
• Next by Date: Re: Bessel K expansion, large argument?
• Previous by thread: Re: List manipulation
• Next by thread: Re: List manipulation