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

Juan Vuletich juan at cuis.st
Wed Mar 19 07:17:13 PDT 2025


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 
> <mailto: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 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/20250319/8178259f/attachment-0001.htm>


More information about the Cuis-dev mailing list