blob: 6a209dd116771ab4cdfb25ad0adf80a493d75845 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
namespace range
{
typedef here = (int current, int end, int step);
bool next_element(var range^ r, var int^ result)
{
if r^.current > r^.end return :false;
result^ = r^.current;
r^.current += r^.step;
return :true;
}
}
() test() {
range r = (10, 20, 1);
for int i in r {
//printnum("%d ", i);
}
for int i in (0, 15, 3) as range {
//printnum("%d ", i);
}
}
// For trying it out
/*
linkname "printf" () printnum(byte^ s, int num);
linkname "main" int main() {
test();
return 0;
}
*/
|