[squeak-dev] The Inbox: Collections-ul.587.mcz

Levente Uzonyi leves at elte.hu
Tue Nov 18 23:08:38 UTC 2014


Hi All,

The reason why I put this into The Inbox instead of The Trunk is that it 
changes the behavior of #sum when the Interval is empty.
The current implementation raises an error - which is correct for a 
Collection which may contain any object - but I think for Intervals the 
preferred behavior is to return 0. Any objections?

Levente

On Tue, 18 Nov 2014, commits at source.squeak.org wrote:

> A new version of Collections was added to project The Inbox:
> http://source.squeak.org/inbox/Collections-ul.587.mcz
>
> ==================== Summary ====================
>
> Name: Collections-ul.587
> Author: ul
> Time: 18 November 2014, 11:53:01.797 pm
> UUID: 30ba8551-0c97-4cf5-b830-9386f272b8d2
> Ancestors: Collections-ul.586
>
> Optimized Interval >> #sum.
>
> =============== Diff against Collections-ul.586 ===============
>
> Item was added:
> + ----- Method: Interval>>sum (in category 'accessing') -----
> + sum
> + 	"Optimized version. Use the sum(n*i - k, i=a..b) = -1/2*(a - b - 1)*(n * (a + b) - 2 * k) equation with a = 1, n = step, b = self size."
> +
> + 	| b |
> + 	b := self size.
> + 	^b * ((b + 1) * step - (step - start * 2)) / 2!
>
>
>


More information about the Squeak-dev mailing list