|
Class: MethodFinder
Object
|
+--MethodFinder
- Package:
- stx:libbasic3
- Category:
- Interface-Tools
- Version:
- rev:
1.132
date: 2024/04/24 07:33:23
- user: stefan
- file: MethodFinder.st directory: libbasic3
- module: stx stc-classLibrary: libbasic3
a utility to find implementing methods by example.
Give it values for a receiver, optional arguments and a desired result,
and it will find methods which do that for you.
Please read the online documentation for details,
or open the MethodFinderView GUI.
[example:]
which message, answers 7, given to 4 with an argument of 3,
and also answers 5, if sent with an arg of 5 to 0
and 10, if send to 5 with an argument of 5:
MethodFinder methodFor: #(
(4 3) 7
(0 5) 5
(5 5) 10
)
You guessed it; it's the '+' message.
[example:]
MethodFinder methodFor: #(
(4) 8
(0) 0
(5) 10
)
copyrightCopyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls)
Copyright (C) 2001 eXept Software AG
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the 'Software'), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Signal constants
-
abortAllSignal
-
return the value of the static variable 'AbortAllSignal' (automatically generated)
-
abortAllSignal: something
-
set the value of the static variable 'AbortAllSignal' (automatically generated)
accessing
-
addAndRemove
-
return the value of the static variable 'AddAndRemove' (automatically generated)
-
addAndRemove: something
-
set the value of the static variable 'AddAndRemove' (automatically generated)
-
approved
-
return the value of the static variable 'Approved' (automatically generated)
-
approved: something
-
set the value of the static variable 'Approved' (automatically generated)
-
blocks
-
return the value of the static variable 'Blocks' (automatically generated)
-
blocks: something
-
set the value of the static variable 'Blocks' (automatically generated)
-
dangerous
-
return the value of the static variable 'Dangerous' (automatically generated)
-
dangerous: something
-
set the value of the static variable 'Dangerous' (automatically generated)
initialization
-
initClassVars
-
The methods we are allowed to use. (MethodFinder initClassVars)
Usage example(s):
MethodFinder initClassVars.
MethodFinder new organizationFiltered: Set
|
-
initClassVars2
-
Additional methods we are allowed to use.
(invoked by MethodFinder initClassVars)
-
initClassVars3
-
Additional methods we are allowed to use.
(invoked by MethodFinder initClassVars2)
instance creation
-
new
-
return an initialized instance
utilities
-
methodFor: dataAndAnswers
-
Return a Smalltalk expression that computes these answers.
accessing
-
answers
-
-
data
-
-
doInsertConversions
-
-
doPermute: aBoolean
-
-
expressions
-
-
realAnswers
-
-
selectors
-
Note the inst var does not have an S on the end
arg maps
-
argMap
-
-
makeAllMaps
-
Make a giant list of all permutations of the args.
To find the function, we will try these permutations of the input data.
receiver, args.
-
mapData
-
Force the data through the map (permutation) to create the data to test.
-
permuteArgs
-
Run through ALL the permutations.
First one was as presented.
-
thisData
-
find a constant
-
allNumbers
-
Return true if all answers and all data are numbers.
-
const
-
See if (^ constant) is the answer
-
constDiv
-
See if (data1 // C) is the answer
-
constLessThan
-
See if (data1 <= C) or (data1 >= C) is the answer
-
constLinear
-
See if (data1 * C1) + C2 is the answer. In the form #(C2 C1) polynomialEval: data1
-
constModulo
-
See if mod, (data1 \\ C) is the answer
-
constMult
-
See if (data1 * C) is the answer
-
constPlus
-
See if (data1 + C) is the answer
initialization
-
cleanInputs: dataAndAnswerString
-
Find and remove common mistakes.
Complain when ill formed.
-
copyFrom: aMethodFinder
-
|m1 m2|
m1 := MethodFinder new.
m2 := MethodFinder new copy:m1
-
copyFrom: aMethodFinder addArg: arg
-
|m1 m2|
m1 := MethodFinder new.
m2 := MethodFinder new copyFrom:m1
-
copyFrom: aMethodFinder data: newData answers: newAnswers
-
aMethodFinder expressions copy.
-
doInsertConversions: aBoolean
-
Modified (format): / 10-03-2024 / 16:26:07 / exept MBP
-
initialize
-
(comment from inherited method)
just to ignore initialize to objects which do not need it
-
load: dataWithAnswers
-
prepare to find a function that takes the data and gives the answers.
Odd list entries are data for it, even ones are the answers.
nil input means data and answers were supplied already.
Usage example(s):
(MethodFinder new)
load: #( (4 3) 7
(-10 5) -5
(-3 11) 8
);
findMessage
|
-
noteDangerous
-
Remember the methods with really bad side effects.
-
organizationFiltered: aClass
-
Return the organization of the class with all selectors defined in superclasses removed. (except those in Object)
-
strictClassCompare: aBoolean
-
-
strictCompare: aBoolean
-
-
test2: anArray
-
look for bad association
-
test3
-
find the modification of the caracter table
-
warnTooManyArguments
-
search
-
exceptions
-
Handle some very slippery selectors.
asSymbol -- want to be able to produce it,
but do not want to make every string submitted into a Symbol!
-
findMessage
-
Control the search.
-
insertConstants
-
see if one of several known expressions will do it.
C is the constant we discover here.
Needs 2 examples
-
insertConversions
-
see if a conversion will do it;
<rcvr> asFilename <selector> <args> -> <string rslt> asFilename
<rcvr> asFilename <selector> <args> -> <boolean rslt>
-
insertConversions: triples
-
see if a conversion will do it;
<rcvr> <aSelector> <selector> <args> -> <string rslt> <aSelector>
<rcvr> <aSelector> <selector> <args> -> <boolean rslt>
-
isArrayOfStrings: someObject
-
-
isByteArray: someObject
-
-
isCharacter: someObject
-
-
isFilename: someObject
-
-
isInteger: someObject
-
-
isNumber: someObject
-
-
isString: someObject
-
-
isStringCollection: someObject
-
-
search: multi
-
if Multi is true, collect all selectors that work.
-
searchForOne
-
Look for and return just one answer
-
simpleSearch
-
Run through first arg's class' selectors, looking for one that works.
-
testPerfect: aSelector
-
Try this selector!
Return true if it answers every example perfectly.
Take the args in the order they are.
Do not permute them.
Survive errors; later cache arg lists.
answers: a vector of expected results
argMap: a vector of arg-orders
thisData: current rcvr+args vector
|