Until
Details
- Until[test] evaluates test repeatedly, effectively with a null body.
- If Break[] is generated in the evaluation of body, the Until loop exits.
- Continue[] exits the evaluation of body and continues the loop.
- Unless an explicit Return is used, the value returned by Until is Null.
- Note that in an example like i=0;Until[i>10,tot+=f[i];i++], the roles of ; and , are reversed relative to C-like programming languages.
Examples
open all close allBasic Examples (1)
Scope (2)
Applications (2)
Properties & Relations (3)
Until[test,body] is effectively equivalent to Until[body;test]:
n = 1;Until[n > 3, Echo[n++]];nn = 1;Until[Echo[n++];n > 3];nUntil[test,body] evaluates body before test:
Until[True, Print["body"]]While[test,body] evaluates test before body:
While[False, Print["body"]]Until and While require opposite tests to reproduce similar behavior:
i = 0;Until[i > 3, Print[i];i++]i = 0;While[Not[i > 3], Print[i];i++]However, the test is evaluated one more time in the While loop:
i = 0;Until[Print[i];i > 3, i++]i = 0;While[Print[i];Not[i > 3], i++]Tech Notes
Related Guides
History
Text
Wolfram Research (2022), Until, Wolfram Language function, https://reference.wolfram.com/language/ref/Until.html.
CMS
Wolfram Language. 2022. "Until." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Until.html.
APA
Wolfram Language. (2022). Until. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Until.html
BibTeX
@misc{reference.wolfram_2026_until, author="Wolfram Research", title="{Until}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Until.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_until, organization={Wolfram Research}, title={Until}, year={2022}, url={https://reference.wolfram.com/language/ref/Until.html}, note=[Accessed: 13-June-2026]}