diff options
Diffstat (limited to 'lua/chupacabra/scratch.lua')
-rw-r--r-- | lua/chupacabra/scratch.lua | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/lua/chupacabra/scratch.lua b/lua/chupacabra/scratch.lua index 9dbe724..9fe504d 100644 --- a/lua/chupacabra/scratch.lua +++ b/lua/chupacabra/scratch.lua @@ -1,17 +1,5 @@ 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) @@ -19,11 +7,11 @@ local function scratch(input) table.insert(stack, {input = input, output = output}) end -local function print_stack() +local function scratch_out() 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)) + print(" output: " .. chupacabra.table_to_string(entry.output)) else print(" output: " .. tostring(entry.output)) end @@ -37,4 +25,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() \ No newline at end of file +scratch_out() \ No newline at end of file |