<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr"><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">Hi Christoph,</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px"><br></span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">let me try to summarize your thoughts:</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px"><br></span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">1. You do not like the name #do:upThrough:.</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">2. You do not agree with just adding the #do:*-version but would like to go "all in" to also support #select* and #collect* and maybe even adapt the #take* protocol.</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px"><br></span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">Yeah, I disagree with you on both. :-) See below Nicolas' comments on #copyUpThrough: maybe also my thoughts on "baby steps" ;-) in my previous answer</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px"><br></span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">Best,</span></span></div><div><span style="font-family: Calibri, Helvetica, sans-serif"><span style="font-size: 16px">Marcel</span></span></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 13:23:16 schrieb Thiede, Christoph <christoph.thiede@student.hpi.uni-potsdam.de>:</p><div style="font-family:Arial,Helvetica,sans-serif">

<div id="divtagdefaultwrapper" style="font-size: 12pt;color: #000000;font-family: Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Marcel,</p>
<p><br>
</p>
<p>I would pay additional attention to the order of arguments. :-)</p>
<p><br>
</p>
<p>#do:upThrough: reads to me as: First do something for every element, then select all elements
<i>(which elements? the original elements or a collected copy?)</i> as long as they do not meet a requirement. Which probably would not be the idea of this selector since it would be unnecessarily slow, wouldn't it?</p>
<p>What would <b>(1 to: 10) do: [:ea | self inform: ea] upThrough: [:ea | false]</b> do? Show zero, one, or ten dialogs?</p>
<p>In the following assuming that the right answer is zero ...:</p>
<p><br>
</p>
<p>I think #selectUpThrough:thenDo: and #selectUpThrough:thenCollect: might fit better. Or maybe #takeUpThrough:... instead. It communicates the order of block execution more transparently and would be consistent and colocated to the existing #select:then[Do|Collect]:
 methods.</p>
<p><br>
</p>
<p>What do you think? :-)</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;color: rgb(0, 0, 0);font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols">
<div name="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif;font-size: ;margin: 0">
<div>
<div class="_rp_T4" id="Item.MessagePartBody">
<div class="_rp_U4 ms-font-weight-regular ms-font-color-neutralDark rpHighlightAllClass rpHighlightBodyClass" id="Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="divtagdefaultwrapper"><span style="font-family: Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="Signature">
<div style="margin:0px"><span style="">
<div><font size="3" color="black"><span style="font-size: 12pt"><a href="http://www.hpi.de/" target="_blank" rel="noopener noreferrer" id="LPNoLP"><font size="2"><span id="LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</span></div>
</div>
</span></div>
</div>
</div>
</div>
</div>
<div><span style="font-size: 10pt;color: #808080"></span></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><span style="font-family: Calibri, sans-serif;color: #000000"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Dienstag, 9. März 2021 09:40:38<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] Collections/Streams | About enumerating a sequence up to a matching query ...</span>
<div> </div>
</div>
<div>
<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>
</div>
</div></blockquote></div>