 
 
 
 
 
 
Re: Getting rid of those deprecated Do[] loops?
- To: mathgroup at smc.vnet.net
- Subject: [mg92801] Re: Getting rid of those deprecated Do[] loops?
- From: Torsten Schoenfeld <schoenf at math.TU-Berlin.DE>
- Date: Mon, 13 Oct 2008 07:05:53 -0400 (EDT)
- References: <gcsctj$8mj$1@smc.vnet.net>
AES wrote:
> Somewhat to my surprise, the construction
> 
> Table[{aa = kk[[1]];  bb = kk[[2]];  aa, bb, xx, yy}, 
>           {kk,  {{1, 10},  {1, 20},  {1, 30},  {2, 10},  {2, 20}, 
> {2,30}}}
>           ] // TableForm
> 
> using a two-dimensional iterator iterator variable kk, actually does 
> this, though the "iterator list" is obviously a bit messy.
You can use Table[] with more than one iterator.  This yields a nested
list of lists which can be flattened with Flatten[] to give the desired
result:
Table[{aa, bb, xx, yy}, {aa, 1, 2}, {bb, 10, 30, 10}]
  // Flatten[#, 1] & // TableForm
-Torsten

