--============_-1268253414==_============ Content-Type: text/plain; charset="us-ascii"
I hesitate to raise this one, since the original code is stamped "di", but the include method on class Interval is manifestly broken. There are some other subtle problems with Intervals, particularly empty intervals and thos with negative steps, but the attached fileIn does at least fix the most obvious problem. As released, include: works only for intervals with a step size of 1.
I was wondering about the pros and cons of re-implementing intervals as two subclasses, one for +ve steps and one for -ve steps. Many of the methods have two cases in their code. Would this be a very minor gain in speed for a significant amount of code bloat.
The problem is for example: (1 to: 20 by: 3) asArray prints as (1 4 7 10 13 16 19 ) and so (1 to: 20 by: 3) asArray includes: 8 prints as false but (1 to: 20 by: 3) includes: 8 prints as true Nevertheless, (1 to: 20 by: 3) occurrencesOf: 8 prints as 0!
--============_-1268253414==_============ Content-Type: text/plain; name="Interval-includes.st" ; x-mac-type="54455854" ; x-mac-creator="522A6368" Content-Disposition: attachment; filename="Interval-includes.st" Content-Transfer-Encoding: imap_stub
0,1767,2,737,0,
--============_-1268253414==_============--
squeak-dev@lists.squeakfoundation.org