m
Move page script moved page USERAPI tinsertbeforeval to WoW:USERAPI tinsertbeforeval without leaving a redirect
m (catfix) |
m (Move page script moved page USERAPI tinsertbeforeval to WoW:USERAPI tinsertbeforeval without leaving a redirect) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 60: | Line 60: | ||
-- tremovebyval: remove a table row given its value | -- tremovebyval: remove a table row given its value | ||
function ''<PREFIX>''_tremovebyval(tab, val) | function ''<PREFIX>''_tremovebyval(tab, val) | ||
for k,v in tab do | for k,v in pairs(tab) do | ||
if(v==val) then | if(v==val) then | ||
table.remove(tab, k); | table.remove(tab, k); | ||
| Line 71: | Line 71: | ||
-- tcount: count table members even if they're not indexed by numbers | -- tcount: count table members even if they're not indexed by numbers | ||
function ''<PREFIX>''_tcount(tab) | function ''<PREFIX>''_tcount(tab) | ||
local n=0 | local n = #tab | ||
if (n == 0) then | |||
for _ in pairs(tab) do | |||
n = n + 1 | |||
end | |||
end | end | ||
return n | return n | ||
end | end | ||
| Line 92: | Line 94: | ||
__NOTOC__ | __NOTOC__ | ||
[[Category:User defined functions]] | [[Category:User defined functions]] | ||