Module:table/invert: Difference between revisions
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
- This module lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
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