[Cuis-dev] finding methods by example

Mark Volkmann r.mark.volkmann at gmail.com
Sun Jan 5 15:26:20 PST 2025


This revealed something that surprised me. I expected this to tell me that
an answer is the collect: method.

double := [:x | x * 2].
Finder methodsByExample: { #(1 2 3). double. #(2 4 6) }.

But I didn't know it would tell me that these methods also return the same
result:

ifNotEmpty:
ifNotNil:
replace:
stonProcessSubObjects:

On Sun, Jan 5, 2025 at 2:50 PM Mark Volkmann <r.mark.volkmann at gmail.com>
wrote:

> 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 Finder class with a
> single class method methodsByExample that does this. It's amazing how
> fast it is!
>
> For example, evaluating the following in a Workspace:
>
> Finder methodsByExample: #(#(1 2 3 4) 2.5)
>
> prints the following in the Transcript:
>
> The following methods on #(1 2 3 4) with no arguments return 2.5:
> - average
> - mean
>
> 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.
>
> My code is in a package at
> https://github.com/mvolkmann/Cuis-Smalltalk-FindByExample. There are more
> examples in the README. I welcome feedback on ways this can be improved.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250105/89cf1882/attachment.htm>


More information about the Cuis-dev mailing list