• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
no edit summary
Line 15: Line 15:     
-- * Collection functions.
 
-- * Collection functions.
 +
 +
function Utils.isArray(xs)
 +
for k, _ in pairs(xs) do
 +
return k == 1
 +
end
 +
return true
 +
end
 +
 +
function Utils.findBy(xs, p)
 +
    if Utils.isArray(xs) then
 +
    for k, v in ipairs(xs) do
 +
            if p(v, k) then
 +
    return v, k
 +
    end
 +
        end
 +
    else
 +
    for k, v in pairs(xs) do
 +
    if p(v, k) then
 +
    return v, k
 +
    end
 +
        end
 +
    end
 +
return nil
 +
end
    
function Utils.find(tbl, v_, k_)
 
function Utils.find(tbl, v_, k_)
cssedit, gkautomate
6,940

edits

Navigation menu