Cello • Range
Methods
range
#define range(...)
Construct a Range object on the stack.
Examples
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.
Definition
struct Range {
var value;
int64_t start;
int64_t stop;
int64_t step;
};
Derives
Implements
- Assign
assign - Cmp
cmpeqneqgtltgele - Doc
namebriefdescriptiondefinition - Get
getsetmemremkey_typeval_type - Iter
foreachiter_inititer_nextiter_type - Len
len - New
newdelconstructdestruct - Show
showlookprintscan