Module:TableTools: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(add a complement function) |
(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. |
||
-- First, get all the key/value pairs in tn. We can't simply make ret equal to tn, |
|||
⚫ | |||
-- as that will affect the value of tn for the whole module. |
|||
⚫ | |||
--]] |
|||
⚫ | |||
⚫ | |||
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, ...) |