MathGroup Archive 1997

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

Search the Archive

Re: Re: Until -Reply

  • To: mathgroup at
  • Subject: [mg7110] Re: [mg7096] Re:[mg7063] Until -Reply
  • From: Allan Hayes <hay at>
  • Date: Sun, 11 May 1997 02:57:10 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Wed, 7 May 1997
Sean Ross <SEAN at>
[mg7096] Re:[mg7063]  Until -Reply

>The forms:
>.....; 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 I suggestion in mg[7075]:

Until[test_, body_]:= While[body;test=!=True]

does execute body first:


Allan Hayes
hay at


Begin forwarded message:

>From: Sean Ross <SEAN at>
>Subject: [mg7110] Re:[mg7063]  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

work fine, but are not a true Until because they don't execute body  

The form:


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:


falls prey to the same problem.  It is not a true until because the  
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[[2]] 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.

  • Prev by Date: Re: Boundary Value Problem
  • Next by Date: Re OPTICA
  • Previous by thread: Re: Until -Reply
  • Next by thread: Re: Until -Reply -Reply