The current implementation of removeElement defined and used in promote-common-constraints.metta utilizes car-atom and cdr-atom to iterate and remove all the atoms in the first input expression from the second one. i.e., It removes the atom A and B given the tuple (A B) from another tuple of (A B D E F) and returns the updated tuple (D E F). We can however have an optimized function that does the same thing by either utilizing the non deterministic nature of MeTTa or some builtin atom operation functions defined at the end of this file.
Context
The implementation of this function should:
yield a performance increase.
simplify our code.
Possible Implementation
A possible implementation of this code could be done using the builtin subtraction function or using the current logic and reducing the iteration by one level using the refactored isMember function found in the issue #134.
Detailed Description
The current implementation of
removeElement
defined and used in promote-common-constraints.metta utilizescar-atom
andcdr-atom
to iterate and remove all the atoms in the first input expression from the second one. i.e., It removes the atomA
andB
given the tuple(A B)
from another tuple of(A B D E F)
and returns the updated tuple(D E F)
. We can however have an optimized function that does the same thing by either utilizing the non deterministic nature of MeTTa or some builtin atom operation functions defined at the end of this file.Context
The implementation of this function should:
Possible Implementation A possible implementation of this code could be done using the builtin
subtraction
function or using the current logic and reducing the iteration by one level using the refactoredisMember
function found in the issue #134.