[Cuis-dev] [Integrated] Re: Fix for SequentiableCollection>>combinations:atATimeDo:
Andres Valloud
ten at smallinteger.com
Sat May 25 13:34:56 PDT 2019
I'd rather have the system not create an enormous amount of garbage
should anyone try something like this:
1 to: 30 :: combinations: 15 atATimeDo: [:x | x doSomething]
If copies were being made, I'd expect the allocation / GC work to vie
for execution time domination.
On 5/25/19 06:05, Hernan Wilkinson via Cuis-dev wrote:
> Hi Luciano,
> thank you for the fix. It is integrated now and I added a couple of
> tests to SequenceableCollectionTest, one when k is cero and another for
> the normal case.
>
> When I wrote the test for the normal case I notice that the collection
> passed as parameter to the block it is always the name and therefore the
> following test fails:
> testCombinationsAtATimeDoWorksAsExpected
>
> | combinations |
>
> combinations := OrderedCollection new.
> 'abc' combinations: 2 atATimeDo: [ :combination | combinations add:
> combination].
>
> self assert: 3 equals: combinations size.
> self assert: (combinations includes: #($a $b)).
> self assert: (combinations includes: #($a $c)).
> self assert: (combinations includes: #($b $c)).
>
> To make it pass I had to make a copy of combination.
> ...
> 'abc' combinations: 2 atATimeDo: [ :combination | combinations add:
> combination *copy*].
> ....
>
> Is that the expected behavior? It looks weird to me... I would expect
> combination to be different collections on each iteration...
>
> Cheers!
> Hernan.
>
> On Thu, May 23, 2019 at 1:13 PM Luciano Notarfrancesco via Cuis-dev
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
>
> The method was failing for the corner case of "combinations of 0
> elements". Here's the fix.
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
>
> --
> *Hernán Wilkinson
> Agile Software Development, Teaching & Coaching*
> *Phone: +54-011*-4893-2057
> *Twitter: @HernanWilkinson*
> *site: http://www.10Pines.com <http://www.10pines.com/>*
> Address: Alem 896, Floor 6, Buenos Aires, Argentina
>
More information about the Cuis-dev
mailing list