Module:table/invert

From Linguifex
Revision as of 15:33, 14 May 2025 by wikt>Theknightwho (Protected "Module:table/invert": Highly visible template/module ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:table/invert/doc

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