mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-23 05:42:28 +01:00
Ignore NaN in table.count_values
This commit is contained in:
parent
2e9db04632
commit
60ce6f3e53
@ -339,9 +339,12 @@ end
|
||||
|
||||
-- Recursively counts occurences of values in a table
|
||||
-- Also counts primitive values like boolean and number
|
||||
-- Does not count NaN, because that doesn't work as a table index
|
||||
function count_values(value)
|
||||
local counts = {}
|
||||
local function count_values_(value)
|
||||
-- Ignore NaN
|
||||
if value ~= value then return end
|
||||
local count = counts[value]
|
||||
counts[value] = (count or 0) + 1
|
||||
if not count and type(value) == "table" then
|
||||
|
Loading…
Reference in New Issue
Block a user