Re: While Loop
- To: mathgroup at smc.vnet.net
- Subject: [mg123555] Re: While Loop
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sun, 11 Dec 2011 03:46:28 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112101230.HAA19372@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
Help actually says: While[test,body] evaluates test, then body, repetitively, until test first fails to give True. In other words, test then body, test then body, test then body... et cetera, until test is anything but True. To get the result you want, you ONLY need to make sure the first test is True. That's usually easy, but if necessary, you can do something like this: initial = True; While[test || initial, initial = False; body] Bobby On Sat, 10 Dec 2011 06:30:33 -0600, Joao <joaopereira9 at 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 > -- DrMajorBob at yahoo.com
- References:
- While Loop
- From: Joao <joaopereira9@gmail.com>
- While Loop