blob: c5e0ee2a5730791b8f655247707bee2efbabb72d (
plain) (
tree)
|
|
local chupacabra = require("chupacabra")
local function table_to_string(t)
local str = "{"
for i, v in ipairs(t) do
if i > 1 then
str = str .. ", "
end
str = str .. tostring(v)
end
str = str .. "}"
return str
end
local stack = {}
local function scratch(input)
local output = chupacabra.run(input, {})
table.insert(stack, {input = input, output = output})
end
local function print_stack()
for i, entry in ipairs(stack) do
print(i .. " input: " .. entry.input)
if type(entry.output) == "table" then
print(" output: " .. table_to_string(entry.output))
else
print(" output: " .. tostring(entry.output))
end
end
end
scratch("3 : + [1 1 1] [2 3 4] @+ @..")
scratch("[2 4 6] 2 @..")
scratch("3 : + [1 1 1] [2 3 4] @+ @..")
scratch("[2 4 6] 2 @..")
scratch("1 2 3 4 5 6 7 @.. [1 2 3 0 5 6 7] @=")
scratch("2 3 +")
scratch("3 : + 6 =")
print_stack()
|