diff options
Diffstat (limited to 'lua/chupacabra/chupacabra.lua')
-rw-r--r-- | lua/chupacabra/chupacabra.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lua/chupacabra/chupacabra.lua b/lua/chupacabra/chupacabra.lua index e64afc3..562dc6b 100644 --- a/lua/chupacabra/chupacabra.lua +++ b/lua/chupacabra/chupacabra.lua @@ -60,6 +60,22 @@ function chupacabra.evaluate(tokens, context) local b = table.remove(stack) table.insert(stack, a) table.insert(stack, b) + elseif token == "=" then + local b = table.remove(stack) + local a = table.remove(stack) + table.insert(stack, a == b) + elseif token == "@=" then + -- checks if the values of 2 equally lenghted arrays are equal, and returns a bit mask of the differences + local b = table.remove(stack) + local a = table.remove(stack) + if #a ~= #b then + error("Arrays must have equal length") + end + local result = {} + for i = 1, #a do + table.insert(result, a[i] == b[i]) + end + table.insert(stack, result) elseif token == "@" then local index = table.remove(stack) local array = table.remove(stack) |