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.
20 lines
364 B
Plaintext
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,
|
|
}
|
|
}
|