range
#define range(...)
Construct a Range object on the stack.
Usage
/* Iterate 0 to 10 */
foreach (i in range($I(10))) {
print("%i\n", i);
}
/* Iterate 10 to 20 */
foreach (i in range($I(10), $I(20))) {
print("%i\n", i);
}
/* Iterate 10 to 20 with a step of 5 */
foreach (i in range($I(10), $I(20), $I(5))) {
print("%i\n", i);
}
/* Iterate 20 to 10 */
foreach (i in range($I(10), $I(20), $I(-1))) {
print("%i\n", i);
}
Integer Sequence
The Range type is a basic iterable which acts as a virtual sequence of integers, starting from some value, stopping at some value and incrementing by some step.
This can be a useful replacement for the standard C for loop with decent performance but returning a Cello Int. It is constructable on the stack with the range macro which makes it practical and easy to use.
struct Range {
var value;
int64_t start;
int64_t stop;
int64_t step;
};
assign cmp eq neq gt lt ge le name brief description definition get set mem rem key_type val_type foreach iter_init iter_next iter_type len new del construct destruct show look print scan