MathGroup Archive 1999

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

Search the Archive

Re: Nested For Loops

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15714] Re: Nested For Loops
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 5 Feb 1999 03:42:13 -0500 (EST)
  • References: <7952ra$kbc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

aranisin wrote in message <7952ra$kbc at smc.vnet.net>...
>Hi,
>
>I am wondering how to write a nested iterative loop in Mathematica.
>
>I want the equivalent of:
>
>For [t=r1; t<r2, t=r1+step,
>    For [z =r3; z< r4, z=r3+step1,
>        Do something here
>        ]
>    ]
>
>Thanks for your help.
>
>-Arani
>

Arani,

Mathematica has For

For [t=0, t<3, t=t+1,
For [z =0, z< 7, z=z+2,
Print[A[t,z]]
]
]
A[0,0]
A[0,2]
A[0,4]
A[0,6]
A[1,0]
A[1,2]
A[1,4]
A[1,6]
A[2,0]
A[2,2]
A[2,4]
A[2,6]

---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565




  • Prev by Date: Problems with Math1.ttf and Math1b.ttf
  • Next by Date: InterpolatingFunction
  • Previous by thread: Re: Nested For Loops
  • Next by thread: Re: Mathematica and OPENSTEP