我有一个要在其中传递名称的表:
names = {'Sachin', 'Ponting', 'Dhoni'}
在其他表格中,我正在传递国家/地区名称:
country = {"India", "Australia", "India"}
我想要像这样的输出表:
out_table = {Sachin="India", Ponting="Australia", Dhoni="India"}

最佳答案

这是一个简单的尝试:

names = {'Sachin', 'Ponting', 'Dhoni'}
countries = {"India", "Australia", "India"}

function table_map(names, countries)
    local out = {}
    for i, each in ipairs(names) do
        out[each] = countries[i]
    end
    return out
end

out_table = table_map(names, countries)

Live repl demo

10-07 17:02