Hi guys I was surprised to see the API of bag for iteration. I propose to add keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences." contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ] and elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences." contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ] Once we agree I will add a bug entry. Stef
Why not #doWithOccurrences: ?? Eg: bag doWithOccurrences: [:element :count | "do something"] I dont'like the keysAndValuesDo: idea, is just an implementation detail. On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr
wrote:
Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
On Aug 12, 2013, at 1:49 AM, Gabriel Cotelli <g.cotelli@gmail.com> wrote:
Why not #doWithOccurrences: ??
Eg: bag doWithOccurrences: [:element :count | "do something"]
I did not see it in fact. it was probably not in the right place.
I dont'like the keysAndValuesDo: idea, is just an implementation detail.
I agree (kind of) but this is polymorphic with hashtable so this is also nice. In fact I was not thinking about implementation when I wrote it.
On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote: Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
On Aug 12, 2013, at 1:49 AM, Gabriel Cotelli <g.cotelli@gmail.com> wrote:
Why not #doWithOccurrences: ??
ok it was a proposal for a new selector :)
Eg: bag doWithOccurrences: [:element :count | "do something"]
I dont'like the keysAndValuesDo: idea, is just an implementation detail.
On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote: Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
#withOccurrencesDo: matches better the rest of the pharo system (#withIndexDo:, etc) :) On Aug 12, 2013, at 9:16 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
On Aug 12, 2013, at 1:49 AM, Gabriel Cotelli <g.cotelli@gmail.com> wrote:
Why not #doWithOccurrences: ??
ok it was a proposal for a new selector :)
Eg: bag doWithOccurrences: [:element :count | "do something"]
I dont'like the keysAndValuesDo: idea, is just an implementation detail.
On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote: Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
+1 Keep it consistent with the rest of the system. On Mon, Aug 12, 2013 at 4:40 AM, Esteban Lorenzano <estebanlm@gmail.com>wrote:
#withOccurrencesDo: matches better the rest of the pharo system (#withIndexDo:, etc) :)
On Aug 12, 2013, at 9:16 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
On Aug 12, 2013, at 1:49 AM, Gabriel Cotelli <g.cotelli@gmail.com> wrote:
Why not #doWithOccurrences: ??
ok it was a proposal for a new selector :)
Eg: bag doWithOccurrences: [:element :count | "do something"]
I dont'like the keysAndValuesDo: idea, is just an implementation detail.
On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
Ok I will add instead of elementsAndOccurrencesDo: On Aug 12, 2013, at 9:40 AM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
#withOccurrencesDo: matches better the rest of the pharo system (#withIndexDo:, etc) :)
On Aug 12, 2013, at 9:16 AM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
On Aug 12, 2013, at 1:49 AM, Gabriel Cotelli <g.cotelli@gmail.com> wrote:
Why not #doWithOccurrences: ??
ok it was a proposal for a new selector :)
Eg: bag doWithOccurrences: [:element :count | "do something"]
I dont'like the keysAndValuesDo: idea, is just an implementation detail.
On Sun, Aug 11, 2013 at 4:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote: Hi guys
I was surprised to see the API of bag for iteration.
I propose to add
keysAndValuesDo: aBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aBlock value: assoc key value: assoc value ]
and
elementsAndOccurrencesDo: aTwoArgBlock "Iterate over the receiver and apply a two argument block on the element and its occurrences."
contents associationsDo: [:assoc | aTwoArgBlock value: assoc key value: assoc value ]
Once we agree I will add a bug entry.
Stef
participants (3)
-
Esteban Lorenzano -
Gabriel Cotelli -
Stéphane Ducasse