Differenze tra le versioni di "Modulo:Wikilib/tables"

Updates for DLPS learnlists *** sovrascritto il testo esistente ***
(Correction for unpack/table.unpack *** sovrascritto il testo esistente ***)
(Updates for DLPS learnlists *** sovrascritto il testo esistente ***)
t.deepSearch, t.deep_search = table.deepSearch, table.deepSearch
 
--[[
 
Returns true if table is empty, that is it has no values.
 
--]]
table.empty = function(tab)
--[[
next() is a stateless iterator, it doesn't modify the table;
need to compare to nil as false is also a value
--]]
return next(tab) == nil
end
t.empty, t.isEmpty, t.is_empty = table.empty, table.empty, table.empty
table.isEmpty, table.is_empty = table.empty, table.empty
 
--[[
t.nonIntPairs, t.non_int_pairs = table.nonIntPairs, table.nonIntPairs
 
-- Predicate search. Returns the index of any value satisfying the predicate,
-- nil if no such values exists in the table. The last parameter iter is
-- optional and specifies the iterator to use (pairs is the default). The
-- predicate takes as arguments the value and the key (the order is reversed
-- because often the key isn't needed)
table.find = function(tab, pred, iter)
iter = iter or pairs
for k, v in iter(tab) do
if pred(v, k) then
return k
end
end
return nil
end
 
-- Linear search. Returns the index of the passed value if found, else nil.