<div dir="ltr"><div>Ah, yes, in a FPL it&#39;s another story...<br></div>By the way Frank, sorry for <a href="http://stackoverflow.com/questions/3527753/why-is-smalltalk-not-a-functional-programming-language">http://stackoverflow.com/questions/3527753/why-is-smalltalk-not-a-functional-programming-language</a>, Smalltalk if ever considered as a FPL, would not only be an impure FPL but also an inefficient one :(<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/4/27 Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sat, 27 Apr 2013, Frank Shearar wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In Schlemiel&#39;s algorithm you have to traverse your string from the<br>
beginning. Here, the problem is that at every step you&#39;re making<br>
String after String after String that you just throw away.<br>
<br>
Unless perhaps you&#39;re suggesting that the Schlemielness comes from not<br>
doing things the way our particular garbage collector like to do<br>
things?<br>
</blockquote>
<br></div>
Your code looks right, and works well in a functional programming language which has the required optimizations to run such code efficiently. But in Smalltalk it creates 2n-1 intermediate strings, where the previous is the prefix of the current one, so each one is longer than the previous, which means that O(n^2) bytes are allocated, filled, read once, and then garbage collected. This means that the runtime cost is also O(n^2).<span class="HOEnZb"><font color="#888888"><br>

<br>
<br>
Levente</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
frank<br>
<br>
On 27 April 2013 22:08, Nicolas Cellier<br>
&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@<u></u>gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="http://en.wikipedia.org/wiki/Schlemiel_the_Painter%27s_algorithm" target="_blank">http://en.wikipedia.org/wiki/<u></u>Schlemiel_the_Painter%27s_<u></u>algorithm</a><br>
<br>
<br>
2013/4/27 &lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Levente Uzonyi uploaded a new version of Tests to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Tests-ul.200.mcz" target="_blank">http://source.squeak.org/<u></u>trunk/Tests-ul.200.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Tests-ul.200<br>
Author: ul<br>
Time: 27 April 2013, 10:08:43.206 pm<br>
UUID: dfe70287-0768-42f9-97b7-<u></u>d7ba6fbd6bb6<br>
Ancestors: Tests-fbs.199<br>
<br>
- avoid suboptimal string concatentation in ReleaseTest &gt;&gt;<br>
#testMethodsWithUnboundGlobals<br>
<br>
=============== Diff against Tests-fbs.199 ===============<br>
<br>
Item was changed:<br>
  ----- Method: ReleaseTest&gt;&gt;<u></u>testMethodsWithUnboundGlobals (in category<br>
&#39;testing&#39;) -----<br>
  testMethodsWithUnboundGlobals<br>
        | unbound |<br>
        unbound := SystemNavigation default methodsWithUnboundGlobals.<br>
        Smalltalk cleanOutUndeclared.<br>
+       self assert: unbound isEmpty description: &#39;Unbound: &#39;, unbound<br>
asCommaString!<br>
-       self assert: unbound isEmpty description: (&#39;Unbound: &#39;, (unbound<br>
reduce: [:acc :each | acc, &#39;, &#39;, each]))!<br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>