mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 17:23:45 +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
|
-- Recursively counts occurences of values in a table
|
||||||
-- Also counts primitive values like boolean and number
|
-- 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)
|
function count_values(value)
|
||||||
local counts = {}
|
local counts = {}
|
||||||
local function count_values_(value)
|
local function count_values_(value)
|
||||||
|
-- Ignore NaN
|
||||||
|
if value ~= value then return end
|
||||||
local count = counts[value]
|
local count = counts[value]
|
||||||
counts[value] = (count or 0) + 1
|
counts[value] = (count or 0) + 1
|
||||||
if not count and type(value) == "table" then
|
if not count and type(value) == "table" then
|
||||||
|
Loading…
Reference in New Issue
Block a user