Oups, spoke too fast. My bad.

I mean that I don't really see a 'matching element' here, it's more that the collection is cut whenever the block given as argument evaluates to a different value.


Le 12/12/2017 à 11:11, Thomas Dupriez a écrit :
Hm, aggregateRuns: separates the collection both after and before the separator.

#(1 2 3 4 1 2 4 5 6 ) aggregateRuns:  [ :each | each = 4]

->    #(#(1 2 3) #(4) #(1 2) #(4) #(5 6))


Le 12/12/2017 à 11:05, Norbert Hartl a écrit :
For me split methods operate on separators which are not included in the result. So name it splitXXX might not be the best idea. And I think it should be more explicit. When the matching elements are included in the result it needs to indicate where the are added. So it is rather something like

xxxAfter:

because the collection is separated after the matching element. What the method does is oppositional to flattenXXX. So if we would have the opposite term of flatten that might be a good candidate. Then it would be something like

roughenAfter:

:) Ok, stupid name but you got the idea.

Norbert





Am 12.12.2017 um 10:50 schrieb Sven Van Caekenberghe <[email protected]>:

#splitWhile: because the block does not define separators but its value indicates runs ?

On 12 Dec 2017, at 10:34, Thomas Dupriez <[email protected]> wrote:

#(1 2 3 4 1 2 3 5 6 ) splitWhen:  [ :each | each = 4]


Le 12/12/2017 à 10:23, Pavel Krivanek a écrit :
Hi,

do you have some proposals for a better name for the message named #aggregateRuns?

(#(1 2 3 4 1 2 3 5 6 ) aggregateRuns:  [ :each | each = 4])
#(#(1 2 3) #(4) #(1 2 3 5 6)).
(#(1 2 3 4 1 2 3 4 5 6 ) aggregateRuns:  [ :each | each = 4])
#(#(1 2 3) #(4) #(1 2 3) #(4) #(5 6)).
((1 to: 12) aggregateRuns:  [ :each | (each \\ 3) = 0])
#(#(1 2) #(3) #(4 5) #(6) #(7 8) #(9) #(10 11) #(12)).
The current comment is:
"Answer a new collection of the same species as the
receiver with elements being collections (of the receiver
species) containing those elements of the receiver
for which the given block consecutively evaluates to
the same object."

https://pharo.fogbugz.com/f/cases/20864/add-examples-to-SequenceableCollection-aggregateRuns

Cheers,
-- Pavel




Reply via email to