Difference between revisions of "Module:TableTools"
Jump to navigation
Jump to search
generate an error message when union and intersection functions are called with no arguments
en>Mr. Stradivarius on tour (check type of prefix and suffix) |
en>Mr. Stradivarius (generate an error message when union and intersection functions are called with no arguments) |
||
Line 49: | Line 49: | ||
--]] | --]] | ||
function p.union(...) | function p.union(...) | ||
local lim = select('#', ...) | |||
if lim == 0 then | |||
error("no arguments passed to 'union'", 2) | |||
end | |||
local ret, trackArrays = {}, {} | local ret, trackArrays = {}, {} | ||
for i = 1, | for i = 1, lim do | ||
local t = select(i, ...) | local t = select(i, ...) | ||
checkType('union', i, t, 'table') | checkType('union', i, t, 'table') | ||
Line 91: | Line 95: | ||
--]] | --]] | ||
function p.valueUnion(...) | function p.valueUnion(...) | ||
local lim = select('#', ...) | |||
if lim == 0 then | |||
error("no arguments passed to 'valueUnion'", 2) | |||
end | |||
local vals, ret = {}, {} | local vals, ret = {}, {} | ||
for i = 1, | for i = 1, lim do | ||
local t = select(i, ...) | local t = select(i, ...) | ||
checkType('valueUnion', i, t, 'table') | checkType('valueUnion', i, t, 'table') | ||
Line 122: | Line 130: | ||
--]] | --]] | ||
function p.intersection(...) | function p.intersection(...) | ||
local lim = select('#', ...) | |||
if lim == 0 then | |||
error("no arguments passed to 'intersection'", 2) | |||
end | |||
local ret, track, pairCounts = {}, {}, {} | local ret, track, pairCounts = {}, {}, {} | ||
for i = 1, lim do | for i = 1, lim do | ||
local t = select(i, ...) | local t = select(i, ...) | ||
Line 155: | Line 166: | ||
--]] | --]] | ||
function p.valueIntersection(...) | function p.valueIntersection(...) | ||
local lim = select('#', ...) | |||
if lim == 0 then | |||
error("no arguments passed to 'valueIntersection'", 2) | |||
end | |||
local vals, ret = {}, {} | local vals, ret = {}, {} | ||
for i = 1, lim do | for i = 1, lim do | ||
local t = select(i, ...) | local t = select(i, ...) |