TABLE.shift新增depth参数

This commit is contained in:
MrZ626
2021-08-08 22:30:23 +08:00
parent e50fe63e02
commit 471f1076c4

View File

@@ -12,13 +12,14 @@ function TABLE.new(val,count)
end
--Get a copy of [1~#] elements
function TABLE.shift(org)
function TABLE.shift(org,depth)
if not depth then depth=1e99 end
local L={}
for i=1,#org do
if type(org[i])~='table'then
if type(org[i])~='table'or depth==0 then
L[i]=org[i]
else
L[i]=TABLE.shift(org[i])
L[i]=TABLE.shift(org[i],depth-1)
end
end
return L