Re: Format for Do loop in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg41938] Re: Format for Do loop in Mathematica
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 11 Jun 2003 03:49:20 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bc465f$krd$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, strange FORTRAN with C-lik comments and since when Return is used by FORTRAN to end a loop. With[{x = 0, y = 0}, Apply[Function[{x, y}, Print[{x, y, x + y, x^2 + y^2}]], Table[{x + i*5, y + 2*j}, {j, 5}, {i, 10}], {2}] ]; Regards Jens Prasad wrote: > > Hi, > > I am using Mathematica and would like to know if it is possible to generate > a Do loop, similar to in Fortran. > > x=0 (*initializing x*) > y-0 (*initializing y*) > Do i = 1,10,1 (*i from 1 to 10 in steps of 1*) > x=x+5 (*increment x by 5*) > Do j=1,5,1 (*j from 1 to 5 in steps of 1*) > y=y+2 > Array1(i,j)=x+y > Array2(i,j)=x^2+y^2 > Print(x,y,Array1(i,j),Array2(i,j)) > Return > Return > > Could some one help to format the above steps in Mathematica or provide a > good reference example. Can the data in Print statement be saved in a Table > format, so that it could be exported as a text or data file. > > Thank You > Prasad