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