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 07:40, 15 January 2016
21 bytes added
,
8 years ago
m
no edit summary
Line 25:
Line 25:
function Utils.map(tbl, fn)
function Utils.map(tbl, fn)
local result = {}
local result = {}
−
for
i
, v in pairs(tbl) do
+
for
_
, v in pairs(tbl) do
−
result
[i] =
fn(v)
+
table.insert(
result
,
fn(v
)
)
end
end
return result
return result
end
end
−
+
function Utils.filter(tbl, pred)
function Utils.filter(tbl, pred)
local result = {}
local result = {}
−
for
i
, v in pairs(tbl) do
+
for
_
, v in pairs(tbl) do
if pred(v) then
if pred(v) then
−
result
[i] =
v
+
table.insert(
result
,
v
)
end
end
end
end
がか
cssedit, gkautomate
7,064
edits