load_results = function(filename) results = {} Global_state.results = {} -- cache ordering for when we modify Data local f, err = App.open_for_reading(filename) if err then error(err) end for line in f:lines() do local _ = -- turn rest of loop (a single giant expr) into a statement to satisfy the Lua parser do_if_match(line, '^%s*(%S+)%s+beat%s+(%S+)%s*$', function(subject, object) table.insert(Global_state.results, {subject, object}) if results[subject] == nil then results[subject] = {} end results[subject][object] = 2 if results[subject].count == nil then results[subject].count = 0 end results[subject].count = results[subject].count+1 if results[object] == nil then results[object] = {} end results[object][subject] = 0 if results[object].count == nil then results[object].count = 0 end results[object].count = results[object].count+1 end) or error('incorrect format: '..line) end f:close() return results end