Add filter function

Works like other programming languages
filter(table, func): return table of items
This commit is contained in:
NullBite 2022-03-20 21:56:24 -04:00
parent 4011493f39
commit 42f3f96a19
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A

View File

@ -77,6 +77,16 @@ function map(table, func)
end
return t
end
function filter(table, func)
local t={}
for k, v in pairs(table) do
if func(v) then
t[k]=v
end
return t
end
end
-- }}}
-- local state variables (do not access within pings) --