Module:table/listToSet

From Linguifex
< Module:table
Revision as of 13:39, 29 July 2023 by Sware (talk | contribs) (Created page with "--[[ { "a", "b", "c" } -> { ["a"] = true, ["b"] = true, ["c"] = true } --]] return function(t) -- checkType("listToSet", 1, t, "table") local set = {} for _, item in ipairs(t) do set[item] = true end return set end")
(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/listToSet/doc

--[[
	{ "a", "b", "c" } -> { ["a"] = true, ["b"] = true, ["c"] = true }
--]]
return function(t)
	-- checkType("listToSet", 1, t, "table")
	
	local set = {}
	for _, item in ipairs(t) do
		set[item] = true
	end
	return set
end