MathGroup Archive 2008

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

Search the Archive

Re: Do -like iteration construct with parallel steps?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84909] Re: [mg84895] Do -like iteration construct with parallel steps?
  • From: Louis Theran <theran at gmail.com>
  • Date: Sat, 19 Jan 2008 05:59:02 -0500 (EST)
  • References: <200801181048.FAA10998@smc.vnet.net> <200801180851.04335.cfo@lanl.gov>

This doesn't really do what I want, since I want to step down several  
lists and ranges of indices at the same time.  (This isn't hard to do  
if allocating a list for the indices isn't a big deal, but the point  
of Do is to avoid that.  Plus, the syntax is nicer.)

It would be really nice if the documentation for nonstandard  
evaluation showed the implementation of any of the iteration constructs.

^L

On Jan 18, 2008, at 10:51 AM, Curtis Osterhoudt wrote:

> Perhaps, as the first step in your Do-loop (or in other iterative  
> constructs),
> you could set the values of all of the variables except one of them  
> (based on
> the looped-over variable), and then just loop over the one.
>   For example, the line "j = 1" becomes part of the body of the Do- 
> loop,
> below:
>
> Do[
>   j = i;
>   Print[{i, j}];
>   Print[i + j],
>
>   {i, 0, 10}
>    ]
>
> {0, 0}
>
> 0
>
> {1, 1}
>
> 2
>
> {2, 2}
>
> 4
>
> {3, 3}
>
> 6
>
> {4, 4}
>
> 8
>
> {5, 5}
>
> 10
>
> {6, 6}
>
> 12
>
> {7, 7}
>
> 14
>
> {8, 8}
>
> 16
>
> {9, 9}
>
> 18
>
> {10, 10}
>
> 20
>
>
>             Hope that helps!
>
>
> On Friday 18 January 2008 03:48:51 Louis Theran wrote:
>> Is there an iteration construct similar to Do, except that it steps
>> all the variables in parallel (as opposed to the ``nested'' way Do
>> does it)?  I didn't see anything in the standard library, and I
>> couldn't figure out how to make one myself, so I figured I'd ask if
>> anybody has written this.  (Even a sample implementation of Do as it
>> is would be helpful.)
>>
>> Thanks.
>>
>> ^L
>
>
>
> -- 
> ==========================================================
> Curtis Osterhoudt
> cfo at remove_this.lanl.and_this.gov
> PGP Key ID: 0x4DCA2A10
> Please avoid sending me Word or PowerPoint attachments
> See http://www.gnu.org/philosophy/no-word-attachments.html
> ==========================================================



  • Prev by Date: Re: Remove space from around elements of GraphicsColumn
  • Next by Date: Re: Keyboard shortcut
  • Previous by thread: Re: Do -like iteration construct with parallel steps?
  • Next by thread: Re: Do -like iteration construct with parallel steps?