You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that operation variables like $left, $intersection and $right are not sealed and they keep their values from item to item. This means that on second item they already have values: { $left <- (), $intersection <- (), $right <- (b c d) } and it is not matchable with the current state of the accum ((a) () (b c d)).
I was trying to use sealed to fix it but I found that sealed cannot seal all variables in a expression. You always need to point which variables to seal. This prevents function to seal expression with variables passed from the outer context because function doesn't know which variables to seal. Thus I think we need to change this behaviour and seal all variables by default except variables in the ignorance set passed by caller. Then it will be possible to use sealed inside fold to make it work as expected.
Lambda case also is covered by sealed op with list of ignored variables, but it requires adding additional parameter to lambda: list of such variables. Variables which are not in this list and in list of parameters is considered to be local.
Summary. This fix this issue one should do the following:
change sealed to have list of ignores variables instead of the list of variables to be sealed
fix metta-examples and other code using sealed
fix foldl-atom to use sealed on each iteration or may be even introduce lambda in the standard metta-library and make foldl-atom get lambda as an argument
Describe the bug
foldl-atom works when provided with a function but if the function is substituted by it's body it breaks
To Reproduce
Expected behavior
both functions should output the same
The text was updated successfully, but these errors were encountered: