<br><br><div class="gmail_quote">On Sun, Feb 20, 2011 at 4:46 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Sun, 20 Feb 2011, Nicolas Cellier wrote:<br>
<br>
snip<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Yes I know, I wrote this thing (before me Smalltalk was not mentionned).<br>
</blockquote>
<br></div>
Thanks.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Maybe it was a bit late at night ;) , anyway I had not so many choices:<br>
- use join: (I think it is integrated in Pharo)<br>
</blockquote>
<br></div>
I don&#39;t like that implementation. To me it&#39;s overengineered and unintuitive. The following is enough for most of cases IMHO:<br>
<br>
Collection &gt;&gt; join: delimiter<br>
<br>
        ^String streamContents: [ :stream |<br>
                self<br>
                        do: [ :each | each putOn: stream ]<br>
                        separatedBy: [ delimiter putOn: stream ] ]<br></blockquote><div><br></div><div>Actually, thinking a little, why not</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br>
Collection &gt;&gt; join: delimiter<br><br>       ^self species streamContents: [ :stream |<br>               self<br>                       do: [ :each | each putOn: stream ]<br>                       separatedBy: [ delimiter putOn: stream ] ]<br>
</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">?</span></div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
This reflects my preference (receiver is the collection, argument is the delimiter) and is not compatible with Pharo&#39;s implementation.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- use String streamContents: [:stream | arrayOfStrings do:<br>
[:eachString | stream nextPutAll: eachString] separatedBy: [stream<br>
nextPutAll: separator]]<br>
 I would have written this form in Smalltalk, however I find the<br>
periphrase a bit long versus other languages<br>
</blockquote>
<br></div>
I see you updated the page, and yes, the phrase is pretty long compared to other languages&#39;.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- use reduce: to find a shorter form comprehensible by foreign<br>
programming language users, though not optimal<br>
</blockquote>
<br></div>
#reduce: combined with #, may give the impression to outsiders that strings have dynamic implementation (like in C++).<br><font color="#888888">
<br>
<br>
Levente</font><div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Of course, it would also be nice to see a Xtreams solution.<br>
<br>
Nicolas<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
*<a href="http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)#join" target="_blank">http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)#join</a><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br>