Content deleted Content added
Theknightwho (talk | contribs) Various optimisations for deepCopy, including a bugfix that stops an infinite loop with recursively-nested tables. |
implement fromIndex in inArray |
||
(One intermediate revision by one other user not shown) | |||
Line 460:
-- inArray
--
-- Returns true if
-- Equivalent to JavaScript array.includes(searchElement) or
-- array.includes(searchElement, fromIndex), except fromIndex is 1 indexed
------------------------------------------------------------------------------------
function p.inArray(
checkType("inArray", 1,
-- if
fromIndex = tonumber(fromIndex)
for _, v in ipairs(arr) do▼
return true▼
fromIndex = #array + fromIndex + 1
if fromIndex < 1 then fromIndex = 1 end
for _, v in ipairs({unpack(array, fromIndex)}) do
if v == searchElement then
▲ return true
end
end
else
if v == searchElement then
return true
end
end
end
Line 482 ⟶ 497:
function p.merge(...)
local arrays = {...}
▲ if #arrays < 2 then
▲ end
local ret = {}
for i, arr in ipairs(arrays) do
|