Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Follow-up on Do[] Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23337] Re: Follow-up on Do[] Question
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 4 May 2000 02:59:07 -0400 (EDT)
  • References: <8elmvq$sii@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Steve,
> But what if I have several expressions that I would like evaluated
> imax times ?
>
> Is there a way to accomplish something like
> Do[expr1, expr2, expr3, . . .exprn, {imax}] ?
> When I try this I get a beep and a message that seems to indicate that
> the second item in the list must be imax which agrees with the online
> help.
>
> The intent here is to evaluate expr1 then expr2 then expr3, . . . then
> exprn. Then expr1 would be evaluated again followed by expr2 and so on
> until each expression is evaluated imax times.

Two suggestions

Do[{expr1, expr2, expr3, . . .exprn}, {imax}] ?

or (note ; instead of ,)

Do[expr1;expr2;expr3; . . .;exprn, {imax}] ?


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

<com3 at ix.netcom*NOSPAM*.com> wrote in message
news:8elmvq$sii at smc.vnet.net...
> Hello,
>
> I recently posted a question on 4/29/00 (msg # 22498) in which I
> recieved emails addressing part 2 and part 3 of my question. Thanks to
> to those that helped.
>
> Part 1 however is of most importance not only for the problem at hand
> but to fill in a large gap in my understanding of Mathematica
> programming. So I will try and sharpen that question.
>
> Am I missing something or is the Do[] construct limited to processing
> only a single command ?
>
> The online help gives the following help on Do.
> Do[expr, {imax}] evaluates expr imax times.
>
> But what if I have several expressions that I would like evaluated
> imax times ?
>
> Is there a way to accomplish something like
> Do[expr1, expr2, expr3, . . .exprn, {imax}] ?
>
> When I try this I get a beep and a message that seems to indicate that
> the second item in the list must be imax which agrees with the online
> help.
>
> The intent here is to evaluate expr1 then expr2 then expr3, . . . then
> exprn. Then expr1 would be evaluated again followed by expr2 and so on
> until each expression is evaluated imax times.
>
> Thanks
>
> Steve
>
>
> For any e-mail responses, please remove *NOSPAM* from my address.
>




  • Prev by Date: Re: Follow-up on Do[] Question
  • Next by Date: Re: plot discrete spectrum
  • Previous by thread: Re: Follow-up on Do[] Question
  • Next by thread: Integrate query