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." Cheers, -- Pavel |
Hi Pavel,
On 12 December 2017 at 10:23, Pavel Krivanek <[hidden email]> wrote: > 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 #groupAround: #selectAround: Cheers, Alistair |
In reply to this post by Pavel Krivanek-3
Hi #(1 2 3 4 1 2 3 5 6 ) collectGroupsWhere: [ :each | each = 4]) 2017-12-12 10:23 GMT+01:00 Pavel Krivanek <[hidden email]>:
|
In reply to this post by Pavel Krivanek-3
#(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 |
We already have #splitOn: with slightly different behavior: (#(1 2 3 4 1 2 3 5 6 ) splitOn: [ :each | each = 4]) So splitOnEach: and splitWhen: would be probably confusing 2017-12-12 10:34 GMT+01:00 Thomas Dupriez <[hidden email]>: #(1 2 3 4 1 2 3 5 6 ) splitWhen: [ :each | each = 4] |
maybe something in the direction of splitOnThresholds:? 2017-12-12 10:38 GMT+01:00 Pavel Krivanek <[hidden email]>:
|
In reply to this post by Thomas Dupriez
#splitWhile: because the block does not define separators but its value indicates runs ?
> On 12 Dec 2017, at 10:34, Thomas Dupriez <[hidden email]> 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 > > |
#splitByGroupingWhile:
The 'split' indicates it's a method to split a collection, and the 'GroupingWhile' expresses how it's done: by grouping elements while they make the block evaluate to the same value. Le 12/12/2017 à 10:50, Sven Van Caekenberghe a écrit : > #splitWhile: because the block does not define separators but its value indicates runs ? > >> On 12 Dec 2017, at 10:34, Thomas Dupriez <[hidden email]> 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 >> |
In reply to this post by Sven Van Caekenberghe-2
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 <[hidden email]>: > > #splitWhile: because the block does not define separators but its value indicates runs ? > >> On 12 Dec 2017, at 10:34, Thomas Dupriez <[hidden email]> 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 >> >> |
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 <[hidden email]>: >> >> #splitWhile: because the block does not define separators but its value indicates runs ? >> >>> On 12 Dec 2017, at 10:34, Thomas Dupriez <[hidden email]> 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 >>> |
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 <[hidden email]>: >>> >>> #splitWhile: because the block does not define separators but its >>> value indicates runs ? >>> >>>> On 12 Dec 2017, at 10:34, Thomas Dupriez >>>> <[hidden email]> 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 >>>> > |
In reply to this post by Pavel Krivanek-3
If short names not work, what about to use something more descriptive like #splitToGroupsThatAlternatelySafisfy: -- Pavel 2017-12-12 10:23 GMT+01:00 Pavel Krivanek <[hidden email]>:
|
In reply to this post by NorbertHartl
Sorry, I’m not sure what I’ve read but it does not seem to be the mail of Pavel :)
Norbert > Am 12.12.2017 um 11:05 schrieb Norbert Hartl <[hidden email]>: > > 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 <[hidden email]>: >> >> #splitWhile: because the block does not define separators but its value indicates runs ? >> >>> On 12 Dec 2017, at 10:34, Thomas Dupriez <[hidden email]> 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 >>> >>> |
In reply to this post by Pavel Krivanek-3
On 12 December 2017 at 17:23, Pavel Krivanek <[hidden email]> wrote:
Split is almost an obvious choice, except I feel the same as Norbert that "split methods operate on separators which are not included in the result." Maybe "groupSomethingXXX"... But after pondering a while for a better name, I wonder what is wrong with the existing? Googling "define aggregate" provides... aggregate (noun) = a whole formed by combining several separate elements. aggregate (verb) = form or group into a class or cluster. The separate elements are runs defined by the block. The existing name seems quite precise to me. cheers -ben |
Ben Coman wrote
> > But after pondering a while for a better name, I wonder what is wrong with > the existing? > Googling "define aggregate" provides... > aggregate (noun) = a whole formed by combining several separate > elements. > aggregate (verb) = form or group into a class or cluster. > > The separate elements are runs defined by the block. > The existing name seems quite precise to me. > > cheers -ben When I read aggregateRuns:, I think the opposite; something combining different runs into a single entity, not something that splits a single collection into constituent runs... Something like (split/collect)runsAccordingTo: sounds more descriptive to my ears, at least. Cheers, Henry -- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html |
2017-12-12 13:01 GMT+01:00 Henrik Sperre Johansen <[hidden email]>: Ben Coman wrote I like groupBy: but in Squeak groupBy: produces a dictionary with unique keys ignoring the multiple sequences... split already carries the meaning of preserving the sequences, but we have to tell to split at a change of value.... Run is also quite explicit...
|
In reply to this post by Pavel Krivanek-3
On Tue, Dec 12, 2017 at 10:23 AM, Pavel Krivanek
<[hidden email]> wrote: > 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 divideOn:? -- Cyril Ferlicot https://ferlicot.fr http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France |
In reply to this post by Nicolas Cellier
On 12 December 2017 at 20:03, Nicolas Cellier <[hidden email]> wrote:
okay. I can understand that perspective.
+1 groupByRuns: is good. cheers -ben |
I'm kind of trying to figure out when I'd want that operation.
groupsWithSeparatorsWhereSeparatatorsMatch: feels like it says what it does
|
groupByRuns: looks good to me.
On Tue, Dec 12, 2017 at 9:48 PM, Todd Blanchard <[hidden email]> wrote: > I'm kind of trying to figure out when I'd want that operation. > > groupsWithSeparatorsWhereSeparatatorsMatch: feels like it says what it does > > On Dec 12, 2017, at 10:19 AM, Ben Coman <[hidden email]> wrote: > > > > On 12 December 2017 at 20:03, Nicolas Cellier > <[hidden email]> wrote: >> >> >> >> 2017-12-12 13:01 GMT+01:00 Henrik Sperre Johansen >> <[hidden email]>: >>> >>> Ben Coman wrote >>> > >>> > But after pondering a while for a better name, I wonder what is wrong >>> > with >>> > the existing? >>> > Googling "define aggregate" provides... >>> > aggregate (noun) = a whole formed by combining several separate >>> > elements. >>> > aggregate (verb) = form or group into a class or cluster. >>> > >>> > The separate elements are runs defined by the block. >>> > The existing name seems quite precise to me. >>> > >>> > cheers -ben >>> >>> When I read aggregateRuns:, I think the opposite; something combining >>> different runs into a single entity, not something that splits a single >>> collection into constituent runs... > > > okay. I can understand that perspective. > >>> >>> >>> Something like (split/collect)runsAccordingTo: sounds more descriptive to >>> my >>> ears, at least. >>> >>> Cheers, >>> Henry >>> >>> >> >> I like groupBy: but in Squeak groupBy: produces a dictionary with unique >> keys ignoring the multiple sequences... >> split already carries the meaning of preserving the sequences, but we have >> to tell to split at a change of value.... >> Run is also quite explicit... >> >> groupByRuns: / splitRuns: > > > +1 > groupByRuns: is good. > > cheers -ben > > |
Free forum by Nabble | Edit this page |