Files
mgmt/examples/lang/range.mcl
Lourenço Vales ae68dd79cb lang: core: iter: Add a range function
This commit implements a range function that mimicks python's range
built-in by having a start, stop, and range argument. There's also
a few examples and tests to mimick Python's examples to guarantee
we're consistent with their behaviour.
2025-04-22 02:37:35 -04:00

20 lines
364 B
Plaintext

import "iter"
import "fmt"
print "range" {
msg => fmt.printf("%v", iter.range(5)),
}
for $i, $v in iter.range(34, 50) {
print [fmt.printf("index is: %d, value is: %d", $i, $v),] {
Meta:autogroup => false,
}
}
for $i, $v in iter.range(10) {
print [fmt.printf("index is: %d", $i),] {
msg => fmt.printf("value is: %d", $v),
Meta:autogroup => false,
}
}