[Cuis-dev] Bag>>#sum:ifEmpty:

Juan Vuletich juan at cuis.st
Tue Nov 15 06:36:37 PST 2022


Hi Francisco,

Just pushed a slight variation of your code. Thanks!

Cheers,
On 11/5/2022 8:56 AM, Francisco Garau via Cuis-dev wrote:
> I've checked in a CuisUniversity-5096 image and here is the optimization:
>
>     *RunArray>>sum *
>
>         "
>
>         /(RunArray new: 4096 withAll: 3) sum =  12288./
>
>         /([(RunArray new) sum] on: Error do: [:ex | ex messageText] )
>         = 'this collection is empty'./
>
>         "
>
>         | initial sum |
>
>         self isEmpty ifTrue: [self errorEmptyCollection].
>
>         initial := self first.
>
>         sum := initial.
>
>         self runsAndValuesDo: [:run :value | sum := sum + (run * value)].
>
>         ^ sum - initial
>
>
> On Sat, 5 Nov 2022 at 10:26, Francisco Garau 
> <francisco.garau at gmail.com <mailto:francisco.garau at gmail.com>> wrote:
>
>     Do we have RunArray in Cuis? We could have a similar optimisation
>     in there
>
>     - Francisco
>
>>     On 2 Nov 2022, at 18:25, Juan Vuletich via Cuis-dev
>>     <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
>>
>>      On 11/1/2022 11:23 PM, Hernán Wilkinson via Cuis-dev wrote:
>>>     yeap, the current implementation is not correct.
>>>     Juan, attached is a change set that fixes it and another with
>>>     the related tests.
>>>
>>>     Cheers!
>>>     Hernan.
>>>
>>>     On Tue, Nov 1, 2022 at 3:39 AM Luciano Notarfrancesco
>>>     <luchiano at gmail.com <mailto:luchiano at gmail.com>> wrote:
>>>
>>>         I’m afk right now so I cannot check, but it sounds like I
>>>         made a mistake. Of course it should be the value of aBlock
>>>         at each element times the number of occurrences.
>>>
>>>         On Tue, 1 Nov 2022 at 07:33 Hernán Wilkinson
>>>         <hernan.wilkinson at 10pines.com
>>>         <mailto:hernan.wilkinson at 10pines.com>> wrote:
>>>
>>>             Hi,
>>>              the implementation of Bag>>#sum: aBlock ifEmpty:
>>>             emptyBlock does not use the parameter aBlock at all and
>>>             assumes that each of the elements answers the message *
>>>             @Luciano Notarfrancesco <mailto:luchiano at gmail.com> the
>>>             implementation is yours and it is very new? Is there a
>>>             reason you did that way?
>>>
>>>             Thanks
>>>             Hernan
>>>
>>>
>>>             -- 
>>>             *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
>>>
>>>
>>>
>>>     -- 
>>>     *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
>>
>>     Hi Hernán,
>>
>>     Your fix disables the optimization Luciano did. I chose to fix
>>     Luciano's code. Did the same for #product: (same bug). Integrated
>>     your tests, and added another one for #product:
>>
>>     Thanks,
>>     -- 
>>     Juan Vuletich
>>     cuis.st  <http://cuis.st>
>>     github.com/jvuletich  <http://github.com/jvuletich>
>>     researchgate.net/profile/Juan-Vuletich  <http://researchgate.net/profile/Juan-Vuletich>
>>     independent.academia.edu/JuanVuletich  <http://independent.academia.edu/JuanVuletich>
>>     patents.justia.com/inventor/juan-manuel-vuletich  <http://patents.justia.com/inventor/juan-manuel-vuletich>
>>     linkedin.com/in/juan-vuletich-75611b3  <http://linkedin.com/in/juan-vuletich-75611b3>
>>     twitter.com/JuanVuletich  <http://twitter.com/JuanVuletich>
>>     -- 
>>     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
>


-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20221115/f7a0e310/attachment-0001.htm>


More information about the Cuis-dev mailing list