[Cuis-dev] Additional collection methods reject:thenDo: and reject:thenCollect:

Ezequiel Birman ebirman77 at gmail.com
Wed Mar 19 11:29:41 PDT 2025


Oops! Thanks.

-- 
Eze

On Wed, 19 Mar 2025 at 14:17, Juan Vuletich <juan at cuis.st> wrote:

> Hi Eze,
>
> Your code would make this fail:
> (1 to: 10) select: [ :i | i even ] thenCollect: [ :i | i * 2 ]
>
> So, I just pushed the two new methods.
>
> Thanks,
>
> On 3/7/2025 1:40 PM, Ezequiel Birman via Cuis-dev wrote:
>
> There was a typo. Here's the corrected version.
>
> --
> Eze
>
> On Fri, 7 Mar 2025 at 16:24, Ezequiel Birman <ebirman77 at gmail.com> wrote:
>
>> Hello
>>
>> I wanted a *reject:thenDo:*. so instead of:
>>
>> | taskbar userInterface |
>>>
>>> "If we were to ommit this, the taskbar wouldn't exist yet, and therefore
>>> taskbar would be initialized to nil"
>>> *self runningWorld doOneCycleNow.*
>>>
>>>
>>> * userInterface := UISupervisor ui. taskbar := userInterface taskbar.*
>>>
>>> "Remove all morphs except for the taskbar. We also leave code windows
>>> intact in case we are recovering from a crash."
>>> *userInterface submorphs*
>>> *    select: [ :morph | (morph isKindOf: CodeWindow) not and: [ morph ~=
>>> taskbar ]]*
>>> *    thenDo: #delete.*
>>
>>
>> I can rewrite:
>>
>>> "Remove all morphs except for the taskbar. We also leave code windows
>>> intact in case we are recovering from a crash."
>>> *userInterface submorphs*
>>> *    reject: [ :morph | (morph isKindOf: CodeWindow) or: [ morph =
>>> taskbar ]]*
>>> *    thenDo: #delete.*
>>
>>
>> While I was at it, I refactored *select:ThenCollect:* to avoid iterating
>> twice, then added a *reject:thenCollect:* just for the sake of symmetry.
>>
>> I attach the changeset in case you find it useful; but I wanted to know
>> what is your opinion on adding tests that exercise higher-level messages
>> like these. If they are needed or wanted, I can also add them to
>> BaseImageTests.
>>
>> --
>> Eze
>>
>
>
> --
> Juan Vuletichcuis.stgithub.com/jvuletichresearchgate.net/profile/Juan-Vuletichindependent.academia.edu/JuanVuletichpatents.justia.com/inventor/juan-manuel-vuletichlinkedin.com/in/juan-vuletich-75611b3twitter.com/JuanVuletich
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250319/598c4813/attachment.htm>


More information about the Cuis-dev mailing list