Adding a new built-in function to the MettaLog interpreter. The process includes updating several files within the codebase to ensure the function is properly defined, implemented, and documented.
Task
Define the Function in stdlib_mettalog.metta:
Add the function definition to stdlib_mettalog.metta so that MettaLog recognizes it as a built-in function.
Example:
;; Public MeTTa
(@doc stringToChars
(@desc "Converts a String to an Expression of Chars")
(@params (
(@param "String to be expanded")))
(@return "Expression with a list of Chars"))
(: stringToChars (-> String Expresson))
;; Implemented from Interpreters
Implement the Function in metta_eval.pl:
Add the implementation of the function to the eval_20 predicate in metta_eval.pl.
Use the existing implementations, like 'stringToChars' and 'charsToString', as a reference.
Example:
eval_20(Eq, RetType, Depth, Self, ['yourFunctionName', Arg1], Result) :-
!, eval_args(Eq, RetType, Depth, Self, Arg1, EvaluatedArg),
/* Your implementation logic here */,
Result = /* Your result here */.
Update the Help Documentation in metta_ontology.pfc.pl:
Add the function to the help documentation in metta_ontology.pfc.pl.
Example:
properties('&corelib', 'yourFunctionName', [category, qhelp("Description of your function."), your_function_name]).
Add Test Cases:
Add relevant test cases to ensure the function behaves as expected.
Somewhere around https://github.com/trueagi-io/metta-wam/wiki create a page for:
Adding a new built-in function to the MettaLog interpreter. The process includes updating several files within the codebase to ensure the function is properly defined, implemented, and documented.
Task
Define the Function in
stdlib_mettalog.metta
:stdlib_mettalog.metta
so that MettaLog recognizes it as a built-in function.Implement the Function in
metta_eval.pl
:eval_20
predicate inmetta_eval.pl
.'stringToChars'
and'charsToString'
, as a reference.Update the Help Documentation in
metta_ontology.pfc.pl
:metta_ontology.pfc.pl
.Add Test Cases:
Acceptance Criteria
metta_interp.pl
, implemented inmetta_eval.pl
, documented inmetta_ontology.pfc.pl
, and tested.Reference Documentation