## [Interval Problem] 2 cents

Jarvis, Robert P. Jarvisb at timken.com
Mon Aug 2 11:50:34 UTC 1999

Perhaps there should be an IntervalIterator class which holds the progress
of an iteration across an Interval.  This would help to separate the concept
of Interval (which would then specify only the start, end, and step values
for the Interval) from the concept of iteration, which produces the
intermediate values.  AND you could conceivably have mutiple iterations
going on simultaneously on the same Interval.  And if you extend this idea
to some of the other collections it might prove useful.  Maybe.  I think...

All that being said, Michael, I really like your rewrite of Interval>>do:.
:-)

Bob Jarvis
The Timken Company

> -----Original Message-----
> From:	Michael Rueger [SMTP:Michael.Rueger.-ND at disney.com]
> Sent:	Friday, July 30, 1999 6:37 PM
> To:	squeak at cs.uiuc.edu
> Subject:	Re: [Interval Problem] 2 cents
>
> Andres Valloud wrote:
>
> > do: aBlock
> >
> >         | aValue |
> >         aValue _ start.
> >         step < 0
> >                 ifTrue: [[stop <= aValue]
> >                                 whileTrue:
> >                                         [aBlock value: aValue.
> >                                         aValue _ aValue + step]]
> >                 ifFalse: [[stop >= aValue]
> >                                 whileTrue:
> >                                         [aBlock value: aValue.
> >                                         aValue _ aValue + step]]
> >
> > I do not see any accessor there.
> But you should ;-)
>
> A really objectified version would go even further like
>
> do: aBlock
> 	[self atEnd] whileFalse: [
> 		aBlock value: self currentValue.
> 		self step]
>
> This would even increase performance because you could optimize
> different atEnd and step methods for e.g. ints and floats or points etc.
> And currentValue could like
>
> currentValue
> 	currentValue ifNil: [currentValue := self start].
> 	^currentValue
>
> Q.E.D.
> ;-)
>
>
> Michael
>
>
> --
>
>  "To improve is to change, to be perfect is to change often."
>                                             Winston Churchill
> +------------------------------------------------------------+
> | Michael Rueger                                             |
> | Phone: ++1 (818) 623 3283        Fax:   ++1 (818) 623 3559 |
> +--------Michael.Rueger.-ND at online.disney.com----------------+