Module:table/invert: Difference between revisions

From Linguifex
Jump to navigation Jump to search
m Protected "Module:table/invert": Highly visible template/module ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))
 
m 1 revision imported
 
(No difference)

Latest revision as of 12:01, 21 April 2026

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