diff options
author | elioat <elioat@tilde.institute> | 2024-06-09 18:11:04 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-06-09 18:11:04 -0400 |
commit | 4dee1f562de247cb202362ab276303b0dc717453 (patch) | |
tree | 0bb249c0caea0430bedf8cce74009893eeee934e /lua/chupacabra/chupacabra.lua | |
parent | 6caa05788b7dd7f59d863e9774b7f61d534cd1fc (diff) | |
download | tour-4dee1f562de247cb202362ab276303b0dc717453.tar.gz |
*
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) |