1 Interval : Collection {
2 var <>start, <>end, <>step;
4 *new { arg start, end, step=1;
5 ^super.newCopyArgs(start, end, step)
8 size { ^end - start div: step + 1 }
10 if (index < 0 or: { index >= this.size }, { ^nil });
11 ^step * index + start;
13 wrapAt { arg index; ^step * (index % this.size) + start }
15 if (index < 0) { ^start };
16 if (index >= this.size) { ^end };
17 ^step * index + start;
20 forBy(start, end, step, function);
23 add { ^this.shouldNotImplement(thisMethod) }
24 put { ^this.shouldNotImplement(thisMethod) }
25 storeArgs { ^[start, end, step] }
27 stream << this.class.name;
28 this.storeParamsOn(stream);
30 printOn { arg stream; this.storeOn(stream) }
36 *new { arg start, size;
37 ^super.newCopyArgs(start, size);
41 for(start, start+size-1, function);
46 if (index < 0 or: { index >= size }, { ^nil });
50 ^(val >= start) and: { (val < this.end) and: { val.frac == 0 }}
53 add { ^this.shouldNotImplement(thisMethod) }
54 put { ^this.shouldNotImplement(thisMethod) }
58 var newRange = this.class.new(start, num);
63 storeArgs { ^[start, size] }
65 stream << this.class.name;
66 this.storeParamsOn(stream);
68 printOn { arg stream; this.storeOn(stream) }