mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 07:13:45 +01:00
Add table.count_equals
This commit is contained in:
parent
494d109833
commit
d4c6468cec
@ -350,6 +350,15 @@ function count(table)
|
||||
return count
|
||||
end
|
||||
|
||||
function count_equals(table, count)
|
||||
local k
|
||||
for _ = 1, count do
|
||||
k = next(table, k)
|
||||
if k == nil then return false end -- less than n keys
|
||||
end
|
||||
return next(table, k) == nil -- no (n + 1)th entry
|
||||
end
|
||||
|
||||
function is_empty(table)
|
||||
return next(table) == nil
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user