<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi all.<div><br></div><div>I like the use of "upThrough" vs. "upTo" to distinguish inclusive from exclusive. Like the existing #copyUpThrough:. (So, not "until".)</div><div><br></div><div>I think that #readStream should not be used in any collection's method (implementation). Instead, we now about #size and sometimes #array, so we should use #do: and similar. Or at least *try* not use it. Yes, I know about #streamContents:, which I think is really valuable.</div><div><br></div><div>Even if we would add something like #collect:upThrough: or #collect:upTo:, I would not want to change the implementation of #collect:. Maybe use #collect: to implement the new interface, but not change it. An [:each | false] would just involve too many redundant checks.</div><div><br></div><div>Considering the order of predicates, I would just support first-order predicates for now because that's what our most recent use cases would need. :-)</div><div><br></div><div>***</div><div><br></div><div>All in all, I would suggest to just add #do:upThrough: and #do:upTo: to Sequenceable collection as well as #upThrough: to (Positionable)Stream. Let's not over-engineer this for now but see where such increment leads us.</div><div><br></div><div>Then, my example use from the beginning could look like this:</div><div><br></div><div>Array streamContents: [:result |</div><div>   <b>aButton withAllOwners</b></div><div><b>      do: [:morph | result nextPut: morph color]</b></div><div><b>      upThrough: [:morph | morph isSystemWindow]</b>].</div><div><br></div><div>Maybe, at a later point, we could evaluate the need for extending #reject:, #select:, #collect:, too. Maybe.</div><div><br></div><div>What do you think?</div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 09.03.2021 08:07:23 schrieb Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div dir="auto">Also the question of inclusion will arise as well as the order of predicates...<div dir="auto"><br></div><div dir="auto">There could also be symetrical once: [:x | x > 10].</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 8 mars 2021 à 23:33, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex;border-left: 1px #ccc solid;padding-left: 1ex;min-width: 500px"><div dir="auto">I like that, it's beginning to be expressive, even better than clojure. However, i think that clojure offers composable predicates thanks to lazyness... like Xtreams.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 8 mars 2021 à 21:38, Jaromir Matas <<a href="mailto:m@jaromir.net" target="_blank" rel="noreferrer">m@jaromir.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin: 0 0 0 .8ex;border-left: 1px #ccc solid;padding-left: 1ex;min-width: 500px">> I am looking for something like #collect:until: or #upToSatisfying:. I do<br>
want the stop element to be included here, not sure about the general case.<br>
><br>
> aButton withAllOwners<br>
>    collect: [:morph | morph color]<br>
>    until: [:morph | morph isSystemWindow].<br>
><br>
<br>
Hi again, ahh so you're actually looking for a generalized collect for any<br>
SequencableCollection or Stream :) Like this?<br>
<br>
(1 to: 100)<br>
        collect: [:x | x squared]<br>
        where: [:x | x even]<br>
        until: [:x | x squared = 2500]<br>
<br>
<br>
collect: collectBlock where: whereBlock until: untilBlock <br>
<br>
        | result supplier |<br>
        supplier := self readStream.<br>
        result := {} writeStream.<br>
        [[supplier atEnd]<br>
            whileFalse: [ | val | <br>
              val := supplier next.<br>
              (whereBlock value: val) ifTrue: [result nextPut: (collectBlock value:<br>
val)].<br>
              (untilBlock value: val) ifTrue: [^result contents]]<br>
        ] value.<br>
        ^result contents<br>
<br>
collect: colBlock until: untilBlock <br>
<br>
        ^self collect: colBlock where: [:each | true] until: untilBlock <br>
<br>
or even:<br>
<br>
collect: colBlock<br>
<br>
        ^self collect: colBlock until: [:each | true]<br>
<br>
<br>
<br>
<br>
-----<br>
^[^ Jaromir<br>
--<br>
Sent from: <a href="http://forum.world.st/Squeak-Dev-f45488.html" rel="noreferrer noreferrer noreferrer" target="_blank">http://forum.world.st/Squeak-Dev-f45488.html</a><br>
<br>
</blockquote></div>
</blockquote></div>
</div></blockquote></div>