79 553
contributi
(Updates for DLPS learnlists *** sovrascritto il testo esistente ***) |
(Formatting *** sovrascritto il testo esistente ***) |
||
local t = {}
-- Stateless iterator on non-integer keys
local nextNonInt = function(tab, key)
local nextKey, nextValue = key, nil
repeat
nextKey, nextValue = next(tab, nextKey)
until type(nextKey) ~=
return nextKey, nextValue
end
local next_non_int = nextNonInt
-- Returns true only if a is lexigographically greater than b
return tostring(a) < tostring(b)
end
--[[
--]]
table.all = function(tab, funct, iter)
return funct(value, key) and acc▼
▲ end, iter)
end
t.all = table.all
--[[
--]]
table.any = function(tab, funct, iter)
return table.fold(tab, false, function(acc, value, key)
▲ end, iter)
end
t.any = table.any
--[[
local dest = {}
for k, v in pairs(value) do
dest[k] = type(v) ==
end
return dest
end
t.copy = table.copy
--[[
--]]
table.deepMerge = function(tab1, tab2)
-- stylua: ignore
-- Better to use mw.clone, so as to keep metatable of items.
local dest = mw.clone(tab1)
end
for key, value in table.nonIntPairs(tab2) do
if
then
dest[key] = table.deepMerge(dest[key], value)
table.deep_merge = table.deepMerge
t.deep_merge, t.deepMerge = table.deepMerge, table.deepMerge
--[[
return k
end
if type(v) ==
--[[
If the last list element is not nil, value
has been found, thus returning
--]]
local valueKeys = { table.deepSearch(v, value) }
if valueKeys[#valueKeys] then
return k, table.unpack(valueKeys)
local mt1 = getmetatable(tab1)
local mt2 = getmetatable(tab2)
if
mt1 and
or type(tab1) ~= "table"
or type(tab2) ~= "table"
then
return tab1 == tab2
end
end
t.filter = table.filter
--[[
table.flat_map = table.flatMap
t.flatMap, t.fat_map = table.flatMap, table.flatMap
--[[
table.flat_map_to_num = table.flatMapToNum
t.flatMapToNum, t.flat_map_to_num = table.flatMapToNum, table.flatMapToNum
-- Returns the input table, but with keys and values swapped.
local dest = {}
for k, v in iter(tab) do
if type(v) ==
dest = table.merge(dest, v)
else
end
t.flatten = table.flatten
--[[
end
t.fold = table.fold
--[[
--]]
---@diagnostic disable-next-line: duplicate-set-field
table.getn = function(self, count)
count = count or
local n = 0
local iterator = (count == true or tostring(count):lower() ==
or pairs
for _ in iterator(self) do
end
t.getn = table.getn
--[[
end
t.keys = table.keys
--[[
end
t.map = table.map
--[[
table.map_to_num = table.mapToNum
t.mapToNum, t.map_to_num = table.mapToNum, table.mapToNum
--[[
--]]
table.merge = function(tab1, tab2)
-- stylua: ignore
-- Better to use mw.clone, so as to keep metatable of items.
local dest = mw.clone(tab1)
end
t.merge = table.merge
-- Stateless iterator to be used in for loops
end
t.search = table.search
--[[
to = to or length
if from < 0 then
from = length + from + 1
end
if to < 0 then
to = length + to + 1
end
end
t.slice = table.slice
--[[
table.table_keys_alias, table.keysAlias, table.keys_alias =
t.tableKeysAlias, t.table_keys_alias, t.keysAlias, t.keys_alias =
table.tableKeysAlias,
table.tableKeysAlias,
table.tableKeysAlias
--[[
end
t.unique = table.unique
--[[
--]]
table.zip = function(tab1, tab2, combinator, iter)
combinator = combinator or function(a, b)
return { a, b }
end
iter = iter or pairs
|