Difference between revisions of "Module:TableTools"

Jump to navigation Jump to search
273 bytes added ,  14:42, 17 December 2013
clone tn rather than returning an altered tn
>Mr. Stradivarius
(add a complement function)
>Mr. Stradivarius
(clone tn rather than returning an altered tn)
Line 211: Line 211:
error("only one argument passed to 'complement' (minimum is two)", 2)
error("only one argument passed to 'complement' (minimum is two)", 2)
end
end
--[[
-- Now we know that we have at least two sets.
-- Now we know that we have at least two sets.
local ret = select(lim, ...)
-- First, get all the key/value pairs in tn. We can't simply make ret equal to tn,
checkType('complement', lim, ret, 'table')
-- as that will affect the value of tn for the whole module.
--]]
local tn = select(lim, ...)
checkType('complement', lim, tn, '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
for i = 1, lim - 1 do
local t = select(i, ...)
local t = select(i, ...)
Anonymous user

Navigation menu