about summary refs log blame commit diff stats
path: root/lua/chupacabra/scratch.lua
blob: 417295037c2ef5a13a53f4f06330026fceb6a7ba (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                        

                

                                            
                                                         

   








                                                            
                                       


                                               
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)
        print("  output: " .. table_to_string(entry.output))
    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] @=")
print_stack()