I have a simple question regarding the use of a proper idiom.I had to create a matrix (n X m) of random values and I used a line similar to this one:
NMatrix withRows: ((1 to: n) collect: [ :i | random next: m ]). Since Smalltalk is so neat for its collection handling, I obviously did not like to write that line. I thought that I did not want to explicitly create the interval, nor use a block that requires an argument that I also don't use. The question, finally, is if there an elegant way of replicating the behaviour of #collect: but without the argument? In my case, I thought it would be great for Integer to have something like #timesCollect: that would allow me to rewrite the line above as: NMatrix withRows: (n timesCollect: [ random next: m ]) Does anyone else think that this would be an useful method to have? Cheers r.
_______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
