[Cuis-dev] finding methods by example

Juan Vuletich juan at cuis.st
Mon Jan 6 10:57:17 PST 2025


Nice! :)

Cheers,

On 1/5/2025 8:26 PM, Mark Volkmann via Cuis-dev wrote:
> 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 <mailto: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.


-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250106/fef9f39c/attachment.htm>


More information about the Cuis-dev mailing list