Add filter function
Works like other programming languages filter(table, func): return table of items
This commit is contained in:
parent
4011493f39
commit
42f3f96a19
10
script.lua
10
script.lua
@ -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) --
|
||||
|
Loading…
x
Reference in New Issue
Block a user