Reimplemented nexus and classes ADTs.

This commit is contained in:
paladin
2026-06-15 12:35:50 +01:00
parent ed2f47db28
commit d28c008c5d
+31 -68
View File
@@ -1,77 +1,40 @@
-- A unique group local ID = 1
local classes = {} local c = {}
classes.input = {} setmetatable(c,{__call = function(c)
classes.output = {} local this = {}
local function class() c[this] = {}
return {} return this
end end})
classes.after = class() c.i = {}
classes.next = class() c.o = {}
classes.chain = class() c.next = c()
classes.inside = class() for char in ("abcdefghijklmnopqrstuvwxyz $;"):match(".") do
for char in "$abcdefghijklmnopqrstuvwxyz ":gmatch(".") do c.i[char] = c()
classes.input[char] = class()
classes.output[char] = class()
end
-- Relation of a class holdin a value between nexus of symbolic index
local function nex(class,v,...)
local this = {class = class, value = value, up = {}, at = {},...}
for index,item in ipairs({...}) do
this.at[item] = index
table.insert(item.up,this)
end end
local function n(class,data,...)
local this = {up = {},class = class,data = data}
table.insert(c[class],this)
return this return this
end end
local i = {}
setmetatable(i,{__call = function(i,this)
-- implication trees, but what about the actions behind them? and things that don't really exist? end})
-- imagination allows things that aren't possible to be possible in our heads at least. local prev
-- an implication tree in a sense.
local function update(root)
-- Objective: find nexus pieces that relate to cookies
-- find the cookies and try to build classes about them
-- try to crunch those classes and find similarities
end
local function action(root)
-- Objective: build hypothetical scenarios from nexus
-- the ones with output classes are most preferred since they can be acted upon
end
-- Main loop
local previous_chain
while true do while true do
prev = n(c[";"],ID,nil)
local input = io.read() local input = io.read()
if input == "end" then return end local mode,input = io.read():match("([#P])(.*)")
local actor local t = ({["$"]=c.i,["#"]=c.o})[mode]
if input:match("^~") then if t then
actor = input.output for char in input:match(".") do
input = input:match("[^#]*") if t[char] then
elseif input:match("[^@]*") then local this = n(t[char],ID,nil)
actor = input.input n(t.next,ID,prev,this)
input = input:match("[^P]*") i(this)
elseif input:match("^#") then prev = this
print("null")
return
elseif input:match("^;") then
previous_chain = null
end
local previous
local chain = nex(classes.chain,1)
if previous_chain then
nex(classes.after,1,previous_chain,chain)
end
for char in input:gmatch(".") do
if classes[char] then
local object = nex(actor[char],1)
nex(classes.inside,1,object,chain)
if previous then nex(classes.next,1,previous,object) end
previous = object
end end
end end
update(chain) end
action(chain) prev = n(t[";"],ID,nil)
end end