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 04:18, 19 February 2017
288 bytes added
,
7 years ago
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