Smart Do

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Smart Do

Francisco Garau-2
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
---



SmartDo.3.cs (897 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Smart Do

Matthias Berth-2
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 <[hidden email]> 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
> ---
>
>
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Smart Do

Edgar J. De Cleene
In reply to this post by Francisco Garau-2
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