<br><br><div class="gmail_quote">On Tue, Nov 2, 2010 at 1:23 PM, Juan Vuletich <span dir="ltr">&lt;<a href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Nicolas Cellier wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I&#39;d say which selector are implemented in Pharo and Cuis ?<br>
We should better converge.<br>
<br>
Nicolas<br>
  <br>
</blockquote>
<br></div>
Hi folks,<br>
<br>
Cuis doesn&#39;t include any of them yet. I can add whatever people prefer. What I&#39;d do different is the implementation:<br>
<br>
fold: aBinaryBlock<div class="im"><br>
   &quot;Evaluate the block with the first two elements of the receiver,<br>
    then with the result of the first evaluation and the next element,<br>
    and so on.  Answer the result of the final evaluation. If the receiver<br>
    is empty, raise an error. If the receiver has a single element, answer<br>
    that element.&quot;<br>
   &quot;<br>
   #(&#39;if&#39; &#39;it&#39; &#39;is&#39; &#39;to&#39; &#39;be&#39; &#39;it&#39; &#39;is&#39; &#39;up&#39; &#39;to&#39; &#39;me&#39;) fold: [:a :b | a, &#39; &#39;, b]<br>
   &quot;<br></div>
   | noPreviousValue |<br>
   noPreviousValue := Object new.    &quot;something that can&#39;t be in the receiver&quot;<br>
   ^self inject: noPreviousValue into: [ :previousValue :each |<br>
       previousValue == noPreviousValue<br>
           ifTrue: [ each ]<br>
           ifFalse: [ aBinaryBlock value: previousValue value: each ]]<br>
<br>
This is easier to understand, and it also makes clear the relation between #fold: (or #reduce:) and #inject:into: .<br></blockquote><div><br></div><div>I disagree.   inject:into: is not particularly easy to understand, whereas both the existing fold: and reduce: are understandable in terms of do:. Also the use of inject:into: isn&#39;t really buying you anything since the logic in the block within the inject:into: usage is as complex as that within fold: or reduce:. Further, this /is/ a lot slower because of the extra level of evaluation (there&#39;s an extra block activation around each element).</div>
<div> </div><div><br></div><div>best,</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Cheers,<br><font color="#888888">
Juan Vuletich<br>
<br>
</font></blockquote></div><br>