Meta Project

The Unofficial Meta Documentation

FOR

Summary

FOR Loop construct that repeats the loop within until every value has been processed.

Category

CONTROLS

Usage

FOR variable reach block

Arguments

variable - description of the value

Refinements

/refinement - description of refinement This method has no refinements Not applicable on category

Description

FOR long description

Example Code

Descriptions and

number: 29
binary-string: ""
for index 32 [
    either is-odd number [
        binary-string: join/with "1" binary-string
    ][
        binary-string: join/with "0" binary-string
    ]
    number: number >> 1 ; this or
]
write/line binary-string

You can also automatically count down or in a given range:

index: to whole! 0
FOR index [9 -9] [write/line index]

We do have to take care of the SIZE! of index or else Meta chooses BYTE! type and never reaches the negative numbers, looping around within the values of a BYTE!

Related

FOR-EACH  
FOREVER  
REPEAT  
WHILE  
UNTIL  

Back to the Meta Methods Reference index