Open main menu
Home
Random
Nearby
Log in
Settings
About Kancolle Wiki
Disclaimers
Kancolle Wiki
Search
Changes
← Older edit
Newer edit →
Module:Core
(view source)
Revision as of 10:57, 14 January 2016
420 bytes added
,
8 years ago
no edit summary
Line 12:
Line 12:
end
end
return m[f](m, unpack(args))
return m[f](m, unpack(args))
+
end
+
+
function Utils.find(tbl, v_, k_)
+
for _, v in pairs(tbl) do
+
if k_ and v[k_] == v_ or not k_ and v == v_ then
+
return true
+
end
+
end
+
return false
+
end
+
+
function Utils.map(tbl, fn)
+
local result = {}
+
for i, v in pairs(tbl) do
+
result[i] = fn(v)
+
end
+
return result
+
end
+
+
function Utils.filter(tbl, pred)
+
local result = {}
+
for i, v in pairs(tbl) do
+
if pred(v) then
+
result[i] = v
+
end
+
end
+
return result
end
end
return Utils
return Utils
がか
cssedit, gkautomate
7,064
edits