about summary refs log tree commit diff stats
path: root/lua/chupacabra/scratch.lua
blob: 9fe504dcda78615edffe16b57b0d44b5cdaf1aae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local chupacabra = require("chupacabra")

local stack = {}

local function scratch(input)
    local output = chupacabra.run(input, {})
    table.insert(stack, {input = input, output = output})
end

local function scratch_out()
    for i, entry in ipairs(stack) do
        print(i .. "  input: " .. entry.input)
        if type(entry.output) == "table" then
            print("  output: " .. chupacabra.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 =")
scratch_out()