It's annoying to have to make each edit in two places. Deducing the table from an array of facts fixes that.
And this will also help save changes on edit. Though I still have some open questions in my mind about how to go back from table to array of facts..
(results is a snapshot of https://en.wikipedia.org/wiki/2023_Cricket_World_Cup)
T2DONXNWMEH4N5S7DVHKA35AHRXWRH3OBFQRS6Z5BHIRVKA5IGJAC
NZ beat Eng
Pak beat Ned
Ban beat Afg
SA beat SL
Ind beat Aus
NZ beat Ned
Pak beat SL
Ind beat Afg
SA beat Aus
NZ beat Ban
Ind beat Pak
Afg beat Eng
Aus beat SL
load_results = function(filename)
results = {}
local f, err = App.open_for_reading(filename)
if err then error(err) end
for line in f:lines() do
local subject, object = line:match('^%s*(%S+)%s+beat%s+(%S+)%s*$')
if subject == nil then
error('incorrect format: '..line)
end
if results[subject] == nil then
results[subject] = {}
end
results[subject][object] = 2
if results[object] == nil then
results[object] = {}
end
results[object][subject] = 0
end
f:close()
return results
end