<div dir="ltr">This revealed something that surprised me. I expected this to tell me that an answer is the <font face="monospace">collect:</font> method.<div><br></div><div><font face="monospace">double := [:x | x * 2].<br>Finder methodsByExample: { #(1 2 3). double. #(2 4 6) }.</font><br></div><div><br></div><div>But I didn't know it would tell me that these methods also return the same result:</div><div><br></div><div><font face="monospace">ifNotEmpty:</font></div><div><font face="monospace">ifNotNil:</font></div><div><font face="monospace">replace:</font></div><div><font face="monospace">stonProcessSubObjects:</font></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Jan 5, 2025 at 2:50 PM Mark Volkmann <<a href="mailto:r.mark.volkmann@gmail.com">r.mark.volkmann@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I understand that the Squeak development environment provides a way to find methods by example. As a fun exercise I wanted to see if I could implement that in Cuis, minus the GUI. I created a <font face="monospace">Finder</font> class with a single class method <font face="monospace">methodsByExample</font> that does this. It's amazing how fast it is!</div><div><div><br></div><div>For example, evaluating the following in a Workspace:</div><div><br></div><div><font face="monospace">Finder methodsByExample: #(#(1 2 3 4) 2.5)</font></div><div><br></div><div>prints the following in the Transcript:</div><div><br></div><div><font face="monospace">The following methods on #(1 2 3 4) with no arguments return 2.5:<br>- average<br>- mean</font><br></div></div><div><br></div><div>The hardest part was discovering all the methods that have side effects which should not be attempted. Perhaps I haven't found all of them yet.</div><div><br></div><div>My code is in a package at <a href="https://github.com/mvolkmann/Cuis-Smalltalk-FindByExample" target="_blank">https://github.com/mvolkmann/Cuis-Smalltalk-FindByExample</a>. There are more examples in the README. I welcome feedback on ways this can be improved.</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>