'From Cuis 2.3 of 22 March 2010 [latest update: #472] on 29 April 2010 at 4:59:58 pm'!

!Float methodsFor: 'intervals' stamp: 'jmv 4/29/2010 13:38'!
to: stop count: n do: aBlock
	"Quite like doing 
		self to: stop by: (stop-self)/(n-1) do: aBlock
	but ensuring that the last time, the block is evaluated exactly for stop, i.e. no rounding error is introduced
	This means that
		0.0 to: 1.0 by: 1.0/9.0 do: [ :each | (each@(each = 1.0)) print ]
	will print false for all  (nine!!!!!!) values, and
		0.0 to: 1.0 by: 0.111111 do: [ :each | (each@(each = 1.0)) print ]
	will print false for all  (ten!!!!!!) values, but
		0.0 to: 1.0 count: 10 do: [ :each | (each@(each = 1.0)) print ]
	will print true in the last iteration
	"
	self to: stop hops: n-1 do: aBlock! !

!Float methodsFor: 'intervals' stamp: 'jmv 4/29/2010 13:40'!
to: stop hops: n do: aBlock
	"Quite like doing 
		self to: stop by: (stop-self)/n do: aBlock
	but ensuring that the last time, the block is evaluated exactly for stop, i.e. no rounding error is introduced.
	Besides, the way for calculating steps inside the interval minimizes rounding error (wrt to incrementing and accumulator)
	This means that
		0.0 to: 1.0 by: 0.1 do: [ :each | (each@(each = 1.0)) print ]
	will print false for all values, but
		0.0 to: 1.0 hops: 10 do: [ :each | (each@(each = 1.0)) print ]
	will print true in the last iteration
	Warning: Having 10 hops means evaluating aBlock 11 times!!
	"
"	self to: stop by: (stop-self)/n do: aBlock"

	| factor |
	factor _ (stop - self) / n.
	aBlock value: self.
	1 to: n-1 do: [ :i |
		aBlock value: i * factor + self ].
	aBlock value: stop! !

