<br><br><div class="gmail_quote">On Thu, May 21, 2009 at 7:40 AM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ah, some s missing!<br>
If only I could evaluate it from gmail!</blockquote><div><br>I could be easy to create a gtalk bot than can receive smalltalk code and evaluates hahaha<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Matrix rows: 2 columns: 5 contents: (Random new next: 10).<br>
<br>
2009/5/21 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; I think it would be more usefull to have some generator behaving like Stream.<br>
&gt; In this particular case, Random is already anamorphic to a Stream:<br>
&gt;<br>
&gt; Matrix row: 2 column: 5 contents: (Random new next: 10).<br>
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
&gt; 2009/5/21 Ramiro Diaz Trepat &lt;<a href="mailto:ramiro@diaztrepat.name">ramiro@diaztrepat.name</a>&gt;:<br>
&gt;&gt; Hi Jerome,<br>
&gt;&gt; Igor also replied with comments regarding the proper use of matrices, so I<br>
&gt;&gt; know now that I must have not been clear in my original mail.   Apologies<br>
&gt;&gt; for that.<br>
&gt;&gt; I was not interested in discussing the Matrix protocol, but weather or not<br>
&gt;&gt; did people consider it useful to add a method that provides the same<br>
&gt;&gt; functionality as #collect: but without the argument, basically as a method<br>
&gt;&gt; called #timesCollect: of the Integer class, much in the same fashion as<br>
&gt;&gt; #timesRepeat:<br>
&gt;&gt; With this method one could write code that produces the same result as:<br>
&gt;&gt; (1 to: n) collect: [ :i | random next: m ]<br>
&gt;&gt; as<br>
&gt;&gt; n timesCollect: [ random next: m ]<br>
&gt;&gt; which does not force the user to visibly create the Interval nor to use a<br>
&gt;&gt; one argument block when the argument is not needed.<br>
&gt;&gt; My intention, hence, was only to ask if people would consider it a nice to<br>
&gt;&gt; have method on the Integer class, as a sibling of #timesRepeat:<br>
&gt;&gt; Cheers<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Thu, May 21, 2009 at 1:11 AM, Jerome Peace &lt;<a href="mailto:peace_the_dreamer@yahoo.com">peace_the_dreamer@yahoo.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Ramiro,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;Ramiro Diaz Trepat ramiro at <a href="http://diaztrepat.name" target="_blank">diaztrepat.name</a><br>
&gt;&gt;&gt; &gt;Wed May 20 08:01:11 UTC 2009 asks:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;I have a simple question regarding the use of a proper idiom.I had to<br>
&gt;&gt;&gt; &gt; create<br>
&gt;&gt;&gt; &gt;a matrix (n X m) of random values and I used a line similar to this one:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;NMatrix withRows: ((1 to: n) collect: [ :i | random next: m ]).<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;Since Smalltalk is so neat for its collection handling, I obviously did<br>
&gt;&gt;&gt; &gt; not<br>
&gt;&gt;&gt; &gt;like to write that line.<br>
&gt;&gt;&gt; &gt;I thought that I did not want to explicitly create the interval, nor use<br>
&gt;&gt;&gt; &gt; a<br>
&gt;&gt;&gt; &gt;block that requires an<br>
&gt;&gt;&gt; &gt;argument that I also don&#39;t use.<br>
&gt;&gt;&gt; &gt;The question, finally, is if there an elegant way of replicating the<br>
&gt;&gt;&gt; &gt;behaviour of #collect: but<br>
&gt;&gt;&gt; &gt;without the argument?<br>
&gt;&gt;&gt; &gt;In my case, I thought it would be great for Integer to have something<br>
&gt;&gt;&gt; &gt; like<br>
&gt;&gt;&gt; &gt;#timesCollect:<br>
&gt;&gt;&gt; &gt;that would allow me to rewrite the line above as:<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;NMatrix withRows: (n timesCollect: [ random next: m ])<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;Does anyone else think that this would be an useful method to have?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In a workspace evaluate:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; picker := Random new .<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; (Matrix rows: 2 columns: 3 ) collect: [ :each | picker next ] .<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; result:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  a Matrix<br>
&gt;&gt;&gt; (0.2668126189461036 0.319686627164337 0.973142751014392<br>
&gt;&gt;&gt;  0.610216298890401 0.905335450966533 0.97292439452043)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You may wish to study the Matrix class and see what else it can do.<br>
&gt;&gt;&gt; The class is a recent contribution by someone who had a need for it.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hth,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Yours in curiosity and service, --Jerome Peace<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>