REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 13-Aug-2010 Edit History  

REBOL 3 Functions: loop

loop  count  block

Evaluates a block a specified number of times.

Arguments:

count [number!] - Number of repetitions

block [block!] - Block to evaluate

See also:

repeat   for   while   until   do   break   continue  

Description

The loop function is the simplest way to repeat the evaluation of a block. This function is very efficient and should be used if no loop counter is required.

loop 3 [print "hi"]
hi
hi
hi

Here's an example that creates a block of 10 random integers:

block: make block! 10
loop 10 [append block random 100]
probe block
[31 25 53 20 40 2 30 79 47 79]

Returned Value

When finished the loop function returns the final value the block:

num: 0
print loop 10 [num: num + 1]
10

Other Notes


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin