TABLE.shift新增depth参数
This commit is contained in:
@@ -12,13 +12,14 @@ function TABLE.new(val,count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Get a copy of [1~#] elements
|
--Get a copy of [1~#] elements
|
||||||
function TABLE.shift(org)
|
function TABLE.shift(org,depth)
|
||||||
|
if not depth then depth=1e99 end
|
||||||
local L={}
|
local L={}
|
||||||
for i=1,#org do
|
for i=1,#org do
|
||||||
if type(org[i])~='table'then
|
if type(org[i])~='table'or depth==0 then
|
||||||
L[i]=org[i]
|
L[i]=org[i]
|
||||||
else
|
else
|
||||||
L[i]=TABLE.shift(org[i])
|
L[i]=TABLE.shift(org[i],depth-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return L
|
return L
|
||||||
|
|||||||
Reference in New Issue
Block a user