Changes

no edit summary
Line 11: Line 11:  
end
 
end
 
return false
 
return false
 +
end
 +
 +
function Utils.map(tbl, fn)
 +
local result = {}
 +
for _, v in pairs(tbl) do
 +
table.insert(result, fn(v))
 +
end
 +
return result
 +
end
 +
 +
function Utils.filter(tbl, pred)
 +
local result = {}
 +
for _, v in pairs(tbl) do
 +
if pred(v) then
 +
table.insert(result, v)
 +
end
 +
end
 +
return result
 
end
 
end
   Line 22: Line 40:  
end
 
end
   −
function Utils.map(tbl, fn)
+
function Utils.imap(arr, fn)
 
local result = {}
 
local result = {}
for _, v in pairs(tbl) do
+
for _, v in ipairs(arr) do
 
table.insert(result, fn(v))
 
table.insert(result, fn(v))
 
end
 
end
 
return result
 
return result
 
end
 
end
+
 
function Utils.filter(tbl, pred)
+
function Utils.ifilter(arr, pred)
 
local result = {}
 
local result = {}
for _, v in pairs(tbl) do
+
for _, v in ipairs(arr) do
 
if pred(v) then
 
if pred(v) then
 
table.insert(result, v)
 
table.insert(result, v)
cssedit, gkautomate
7,064

edits