Module:Utils: Difference between revisions
CompactStar (talk | contribs) No edit summary |
Move table_contains to top and rework on it |
||
Line 1: | Line 1: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local p = {} | local p = {} | ||
-- Check if a table contains x | |||
function p.table_contains(tbl, x) | |||
for i = 1, #tbl do | |||
if x == tbl[i] then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
-- evaluate input on error use default; cannot be used with {{#invoke:}} | -- evaluate input on error use default; cannot be used with {{#invoke:}} | ||
Line 208: | Line 218: | ||
end | end | ||
return result | return result | ||
end | end | ||
return p | return p |