[Date Index] [Thread Index] [Author Index]
Re: Until -Reply
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.