Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7125 > unrolled thread

Re: While Loop

Started byBob Hanlon <hanlonr357@gmail.com>
First post2011-12-11 08:59 +0000
Last post2011-12-11 08:59 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: While Loop Bob Hanlon <hanlonr357@gmail.com> - 2011-12-11 08:59 +0000

#7125 — Re: While Loop

FromBob Hanlon <hanlonr357@gmail.com>
Date2011-12-11 08:59 +0000
SubjectRe: While Loop
Message-ID<jc1ref$t4p$1@smc.vnet.net>
The test is evaluated first; however, you can achieve the effect of
its being evalated last.

n = 0;

While[n < 3, Print[n]; n++]

0

1

2

n = 0;

While[n < 3, Print[n++]]

0

1

2

n = 0;

While[n < 3, n++; Print[n]]

1

2

3

n = 0;

While[n++ < 3, Print[n]]

1

2

3


Bob Hanlon


On Sat, Dec 10, 2011 at 7:30 AM, Joao <joaopereira9@gmail.com> wrote:
> Hi, everybody
>
> Could someone help me regarding the While Loop.
>
> While[test,body]
>
> In the help "While" it is stated that the test may be evaluated at the end of the loop, instead of at the beginning. However in the tutorial on Loops and Control structures it is stated that the While always evaluates the test at the beginning.
>
> I would like to know if it is really possible to evaluate the test inside de While at the end of the loop. This is a feature that would be useful for what I'm doing, however I haven't been able to get it working and I don't know, taking into consideration the above, if I am doing something wrong or if it is really not possible to do.
>
> Thanks in advance
>
> Joao
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web