The getGuardSetExp function used in the delete-inconsistent-handle.metta file and defined in the rte-helpers.metta file can be optimized since the operation doesn't necessarily need to be done using iteration. The current implementation is iterating over the expression to determine whether an atom is fit to be considered as a guradSet or not. However this operation can be done in parallel.
This function can be refactored so that it can return guardSets of a given expression without the need to iterator over the expression one at a time.
Context
Refactoring the function as such:
reduces the overhead of using car-atom and cdr-atom for iteration over the atom one at a time.
have better performance if done in parallel.
Possible Implementation
A possible implementation could be to make the getGuardSetExp function a non deterministic function that takes an expression and uses superpose to determine whether each item is fit for a guardSet or not.
For this purpose, one can define another partial function that takes an atom or expression and returns it if it is fit for a guardSet. This helper function can then be mapped over the superposed atom to be used as a filter.
Detailed Description
The
getGuardSetExp
function used in the delete-inconsistent-handle.metta file and defined in the rte-helpers.metta file can be optimized since the operation doesn't necessarily need to be done using iteration. The current implementation is iterating over the expression to determine whether an atom is fit to be considered as aguradSet
or not. However this operation can be done in parallel.This function can be refactored so that it can return
guardSets
of a given expression without the need to iterator over the expression one at a time.Context
Refactoring the function as such:
car-atom
andcdr-atom
for iteration over the atom one at a time.Possible Implementation
A possible implementation could be to make the
getGuardSetExp
function a non deterministic function that takes an expression and usessuperpose
to determine whether each item is fit for aguardSet
or not. For this purpose, one can define another partial function that takes an atom or expression and returns it if it is fit for aguardSet
. This helper function can then be mapped over the superposed atom to be used as a filter.