Re: Until -Reply
- To: mathgroup at smc.vnet.net
- Subject: [mg7096] Re:[mg7063] Until -Reply
- From: Sean Ross <SEAN at mail.creol.ucf.edu>
- Date: Wed, 7 May 1997 01:58:19 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
The big difference between a While and an Until is that the Until performs its test after the execution of the body and while tests first. The forms: Until[test_,body_]:=While[Unevaluated[Not[test]],body]; or yours Until[test_,body_]:=While[test=!=True,body]; work fine, but are not a true Until because they don't execute body first. The form: Until[test_,body_]:=body;While[Unevaluated[Not[test]],body]; works for simple cases in which the variables in test are in existence independent of body, but does not work when the definitions necessary for execution of the test are first performed in body, so this is not a true Until structure either. Your suggestion applied to a true Until: Until[test_,body_]:=body;While[test=!=True,body] falls prey to the same problem. It is not a true until because the variables necessary to perform the test cannot be first defined in body, so it is not truly an independent structure. As an example for this definition problem, imagine a test involving the second element of a List, but the list is not defined anywhere except in body. Mathematica seems to scan the entire structure to make sure that List[] makes sense before it executes any of it rather than waiting until the test is to be performed to see if it makes sense. What I need is an attribute that will stop mathematica from examining or precompiling test or While so that it only looks at it after body is executed for the first time. Thanks for your help.