<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 18, 2014 at 3:08 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi All,<br>
<br>
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.<br>
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?</blockquote><div><br></div><div>I want to add a non-objection, an anti-objection, or whatever will cause you to put this in trunk ;-)  Clearly the bug is in the original sum.  It should read</div><div><br></div><div><div>sum</div><div><span class="" style="white-space:pre">        </span>&quot;Compute the sum of all the elements in the receiver&quot;</div><div><br></div><div><span class="" style="white-space:pre">        </span>^self isEmpty ifTrue: [0] ifFalse: [self reduce:[:a :b| a + b]]</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><font color="#888888">Levente</font></span><div class=""><div class="h5"><br>
<br>
On Tue, 18 Nov 2014, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
A new version of Collections was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-ul.587.mcz" target="_blank">http://source.squeak.org/<u></u>inbox/Collections-ul.587.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-ul.587<br>
Author: ul<br>
Time: 18 November 2014, 11:53:01.797 pm<br>
UUID: 30ba8551-0c97-4cf5-b830-<u></u>9386f272b8d2<br>
Ancestors: Collections-ul.586<br>
<br>
Optimized Interval &gt;&gt; #sum.<br>
<br>
=============== Diff against Collections-ul.586 ===============<br>
<br>
Item was added:<br>
+ ----- Method: Interval&gt;&gt;sum (in category &#39;accessing&#39;) -----<br>
+ sum<br>
+       &quot;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.&quot;<br>
+<br>
+       | b |<br>
+       b := self size.<br>
+       ^b * ((b + 1) * step - (step - start * 2)) / 2!<br>
<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>