The isMember function used in the rte-helpers.metta file and defined in the general-helpers.metta file can be optimized since the operation can be done in parallel utilizing the non deterministic nature of MeTTa. The current implementation is iterating over the expression to determine whether an atom exists in a given expression or not.
Context
Refactoring the function as such:
reduces the overhead of using car-atom and cdr-atom.
have better performance if done in parallel.
Possible Implementation
A possible implementation could be utilizing the builtin intersection function found in metta. (Documentation about this and similar other functions can be found here). One can try to find the intersection of the input atom and the rest of the atom to make sure the atom exists in there or not.
Detailed Description
The
isMember
function used in the rte-helpers.metta file and defined in the general-helpers.metta file can be optimized since the operation can be done in parallel utilizing the non deterministic nature of MeTTa. The current implementation is iterating over the expression to determine whether an atom exists in a given expression or not.Context
Refactoring the function as such:
car-atom
andcdr-atom
.Possible Implementation
A possible implementation could be utilizing the builtin
intersection
function found in metta. (Documentation about this and similar other functions can be found here). One can try to find the intersection of the input atom and the rest of the atom to make sure the atom exists in there or not.