HomeManualTopicsTypesSymbols

std::repeat

invoke a statement sequence for a specific number of times

Parameters

n
how often to invoke *body*
body
the statement sequence to invoke
finally (default: pass)
a function to return selected variables to the caller

Results

None

Description

The statement sequence body is invoked exactly n times.

n must be a numeric value. If it is not greater than 0 than body will not be called at all. n might also be a negative number (in which case body will not be called).

To start the next iteration of the loop a tail call to the next-function has to be performed.

To exit from the loop a tail call to the break-function has to be performed or one or more results have to be returned.

Example

repeat 10: print! '*' next! println!

Output

**********

Example

$value 1 $n 1 $result repeat 10 : inc &n times &value n if value > 100 -> value next -> value println! result

Output

120

Example

$value 1 $n 1 $result repeat 10 : inc &n times &value n if value > 1'000'000 -> value next -> value println! result

Output

3628800

Topic

Loops

See also

std::loop a simple "loop"
std::while a "while" loop
std::while_not a "while" loop
std::from_to a loop iterating over a sequence of values
std::from_to_by a loop iterating over a sequence of values