<div dir="ltr">Always in favour of modularity and stripping the core of unused messages.</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, 7 Mar 2025 at 17:39, Gerald Klix via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
On 3/7/25 5:24 PM, Ezequiel Birman via Cuis-dev wrote:<br>
<blockquote type="cite">
<pre>Hello
I wanted a *reject:thenDo:*. so instead of:
| taskbar userInterface |
</pre>
<blockquote type="cite">
<pre>"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.*
</pre>
</blockquote>
<pre>I can rewrite:
</pre>
<blockquote type="cite">
<pre>"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.*
</pre>
</blockquote>
<pre>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.
</pre>
<br>
<fieldset></fieldset>
</blockquote>
Hi Ezequiel, Hello List Members,<br>
<br>
what do think about a package that adds some extensions methods<br>
to the collection classes? I attached such a package and its test
package.<br>
<br>
Its focus is currently on adding something similar<br>
to Python's list comprehensions to Cuis/Haver.<br>
<br>
This code
(<a href="https://hg.sr.ht/~cy-de-fect/GF3/browse/gf/base.py?rev=tip#L290" target="_blank">https://hg.sr.ht/~cy-de-fect/GF3/browse/gf/base.py?rev=tip#L290</a>):<br>
<br>
<pre> <span>def</span> <span>dominates</span><span>(</span><span>dom</span><span>,</span> <span>sub</span><span>,</span>
<span>orders</span><span>=</span><span>tuple</span><span>(</span><span>dict</span><span>((</span><span>t</span><span>,</span> <span>i</span><span>)</span> <span>for</span> <span>i</span><span>,</span> <span>t</span> <span>in</span> <span>enumerate</span><span>(</span><span>mro</span><span>))</span>
<span>for</span> <span>mro</span> <span>in</span> <span>mros</span><span>)):</span>
<span>if</span> <span>dom</span> <span>is</span> <span>sub</span><span>:</span>
<span>return</span> <span>False</span>
<span>return</span> <span>all</span><span>(</span><span>order</span><span>[</span><span>d</span><span>]</span> <span><=</span> <span>order</span><span>[</span><span>s</span><span>]</span>
<span>for</span> <span>d</span><span>,</span> <span>s</span><span>,</span> <span>order</span> <span>in</span> <span>zip</span><span>(</span><span>dom</span><span>,</span> <span>sub</span><span>,</span> <span>orders</span><span>))</span></pre>
<br>
roughly translates to this piece of Cuis code:<br>
<br>
orders := someHierarchies collect: [ :hierarchy | |
order |<br>
order := Dictionary ofRoom: hierarchy size.<br>
hierarchy withIndexDo: [ :type :index | order at:
type put: index ].<br>
order ].<br>
dominates := [ :dom :sub |<br>
dom ~~ sub and: [<br>
{ dom. sub. orders } zippedAllSatisfy: [ :d :s
:order |<br>
(order at: d) <= (order at: s) ] ] ].<br>
<br>
<br>
Have fun and Best Regards,<br>
<br>
Gerald<br>
</div>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div>