The following version of do works in a slighltly smarter way. It's a more generic version of #pairsDo:
#( 1 2 3 ) smartDo: [:a | Transcript cr; show: a] #( 1 1 2 2 3 3 ) smartDo: [:a :b | Transcript cr; show: a + b] #( 1 1 1 2 2 2 3 3 3 ) smartDo: [:a :b :c | Transcript cr; show: a + b + c]
I'm attaching a ChangeSet with the implementation. (Is this the best to contribute things? or should I package it in some other format?)
Cheers, Francisco --- That which we call a rose by another name would smell as sweet -- WS ---
how about calling it tuplesDo:, or partitionsDo:? How about this comment "Evaluate aBlock for the receiver, consuming as many elements at a time as the block has arguments".
By the way, ist there a method #partition: that takes a collection and splits it into chunks of a given size?
Matthias
On 11/3/06, Francisco Garau francisco.garau@gmail.com wrote:
The following version of do works in a slighltly smarter way. It's a more generic version of #pairsDo:
#( 1 2 3 ) smartDo: [:a | Transcript cr; show: a] #( 1 1 2 2 3 3 ) smartDo: [:a :b | Transcript cr; show: a + b] #( 1 1 1 2 2 2 3 3 3 ) smartDo: [:a :b :c | Transcript cr; show: a + b + c]
I'm attaching a ChangeSet with the implementation. (Is this the best to contribute things? or should I package it in some other format?)
Cheers, Francisco
That which we call a rose by another name would smell as sweet -- WS
Francisco Garau puso en su mail :
I'm attaching a ChangeSet with the implementation. (Is this the best to contribute things? or should I package it in some other format?)
Cheers, Francisco
Francisco:
A couple of students just they need something like #(0@11 17@0 0@92 26@0 0@98 27@0) smartDo: [:a :b | newCollection add: (a + b)].
Gracias en nombre de Luciana y Marina!
Edgar
__________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam �gratis! �Abr� tu cuenta ya! - http://correo.yahoo.com.ar
squeak-dev@lists.squeakfoundation.org