Meta Project

The Unofficial Meta Documentation

UNTIL

Summary

UNTIL Loop construct that repeats the loop until some condition is met.

Category

CONTROLS

Usage

UNTIL conditionals block

Arguments

conditionals - a part of code within parenthesis. At the end there is a conditional statement

block - this block is mostly empty, but it can be filled with Meta code.

Refinements

This method has no refinements

Description

UNTIL Loop construct that repeats the loop until some condition is met.

Example Code

Until has a slightly different form than you might be familiar with when you have a Rebol background. This has to do with the fact that the corresponding C structure does not allow the form without the extra parenthesis. On the other hand, it does allow for a flexible use of the UNTIL 'statement', because the empty block in the example below can also be used to hold Meta code to perform. This is the Prime factorization example.

n: 5251
m: 2
s: 1
a: ""
write/line "start"
until (
    either 0 = modulo n m [
        n: to whole! n / m
        write "found factor: "
        write/line m
    ][
        m: m + s
        s: 2
    ]
    if n < (m * m ) [
        write "found factor: "
        write/line n
        n: 1
    ]
    n = 1
) []
write/line "end"

Related

FOR-EACH  
FOREVER  
REPEAT  
WHILE  
FOR  

Back to the Meta Methods Reference index