Jump to content

Module:table/invert

Wiktionary වෙතින්


local pairs = pairs

--[==[
Invert a table. For example, {invert({ "a", "b", "c" })} -> { { a = 1, b = 2, c = 3 }}]==]
return function(t)
	local map = {}
	for k, v in pairs(t) do
		map[v] = k
	end
	return map
end
"https://si.wiktionary.org/w/index.php?title=Module:table/invert&oldid=221335" වෙතින් සම්ප්‍රවේශනය කෙරිණි