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: [mg84922] Re: [mg84895] Do -like iteration construct with parallel steps?
  • From: Curtis Osterhoudt <cfo at lanl.gov>
  • Date: Sat, 19 Jan 2008 06:05:50 -0500 (EST)
  • Organization: LANL
  • References: <200801181048.FAA10998@smc.vnet.net>
  • Reply-to: cfo at lanl.gov

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: Re: Point[] shapes at different sizes
  • Next by Date: Re: Point[] shapes at different sizes
  • Previous by thread: Do -like iteration construct with parallel steps?
  • Next by thread: Re: Do -like iteration construct with parallel steps?