Module:TableTools: Difference between revisions

clone tn rather than returning an altered tn
Enwikipedia>Mr. Stradivarius
(add a complement function)
Enwikipedia>Mr. Stradivarius
(clone tn rather than returning an altered tn)
Line 211:
error("only one argument passed to 'complement' (minimum is two)", 2)
end
--[[
-- Now we know that we have at least two sets.
-- First, get all the key/value pairs in tn. We can't simply make ret equal to tn,
local ret = select(lim, ...)
-- as that will affect the value of tn for the whole module.
checkType('complement', lim, ret, 'table')
--]]
local rettn = select(lim, ...)
checkType('complement', lim, rettn, 'table')
local ret = {}
for k, v in pairs(tn) do
ret[k] = v
end
-- Remove all the key/value pairs in t1, t2, ..., tn-1.
for i = 1, lim - 1 do
local t = select(i, ...)