- edited description
Comparing the content of Lua tables is not supported
For example, comparing whether the interpretation of two function terms is the same is impossible:
Voc {
type Action constructed from {accelerate,decelerate,turn}
Do(Time, Action)
}
In RobotSimulator wil ik die acties nu uitvoeren als volgt:
for t in tuples(plan[voc::Do].ct) do
if (t[2]==plan[voc::accelerate]())
self.accelerate()
elseif (t[2]==plan[voc::decelerate]())
self.decelerate()
elseif
...
end
end
Als ik [voc::Do].ct
uitprint geeft dit bv (0,accelerate).(4,accelerate).(6,decelerate).(7,decelerate).(8,accelerate).(9,accelerate)
.
Als ik dan echter de elementen opsplits via die tuples geeft t[2]
een compound, die ik niet meer kan uitprinten en die geeft ook false bij elke bovenstaande test. Hoe krijg ik nu die Action uit die compound halen om ermee te kunnen vergelijken?
Comments (8)
-
reporter -
reporter het probleem is dat de == operator in Lua enkel de variabele zelf vergelijkt en niet de inhoud, waardoor == dus false is.
Blijkbaar hebben we zoiets nog niet nodig gehad in idp en zit een interne vergelijking er nog niet in :) Maar ik zal die maandag implementeren en je mag ervan uitgaan dat de functie "equal" zal heten (dus equal(a,b) ipv a==b om de inhoud te vergelijken).
-
reporter - changed title to Comparing the contens of Lua tables is not supported
-
assigned issue to
- marked as enhancement
- edited description
-
- changed title to Comparing the content of Lua tables is not supported
-
- edited description
-
reporter - changed status to resolved
Fixes
#732: added an equal function that can compare the internals of lua tables if they are idp elements.→ <<cset 5daf840f9f49>>
-
reporter Fixes
#732: added an equal function that can compare the internals of lua tables if they are idp elements.→ <<cset 46d809919746>>
-
reporter Merged in equal_lua_pop (pull request #247)
Fixes
#732: equal operation on (tuples of) domain elements→ <<cset ec8d28f51b93>>
- Log in to comment