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 classes = {}
classes.input = {}
classes.output = {}
local function class()
return {}
end
classes.after = class()
classes.next = class()
classes.chain = class()
classes.inside = class()
for char in "$abcdefghijklmnopqrstuvwxyz ":gmatch(".") do
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)
local ID = 1
local c = {}
setmetatable(c,{__call = function(c)
local this = {}
c[this] = {}
return this
end})
c.i = {}
c.o = {}
c.next = c()
for char in ("abcdefghijklmnopqrstuvwxyz $;"):match(".") do
c.i[char] = c()
end
local function n(class,data,...)
local this = {up = {},class = class,data = data}
table.insert(c[class],this)
return this
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?
-- imagination allows things that aren't possible to be possible in our heads at least.
-- 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
end})
local prev
while true do
prev = n(c[";"],ID,nil)
local input = io.read()
if input == "end" then return end
local actor
if input:match("^~") then
actor = input.output
input = input:match("[^#]*")
elseif input:match("[^@]*") then
actor = input.input
input = input:match("[^P]*")
elseif input:match("^#") then
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
local mode,input = io.read():match("([#P])(.*)")
local t = ({["$"]=c.i,["#"]=c.o})[mode]
if t then
for char in input:match(".") do
if t[char] then
local this = n(t[char],ID,nil)
n(t.next,ID,prev,this)
i(this)
prev = this
end
end
update(chain)
action(chain)
end
prev = n(t[";"],ID,nil)
end