微调table扩展
This commit is contained in:
@@ -16,10 +16,10 @@ function TABLE.shift(org,depth)
|
|||||||
if not depth then depth=1e99 end
|
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'or depth==0 then
|
if type(org[i])=='table'and depth>0 then
|
||||||
L[i]=org[i]
|
|
||||||
else
|
|
||||||
L[i]=TABLE.shift(org[i],depth-1)
|
L[i]=TABLE.shift(org[i],depth-1)
|
||||||
|
else
|
||||||
|
L[i]=org[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return L
|
return L
|
||||||
@@ -30,10 +30,10 @@ function TABLE.copy(org,depth)
|
|||||||
if not depth then depth=1e99 end
|
if not depth then depth=1e99 end
|
||||||
local L={}
|
local L={}
|
||||||
for k,v in next,org do
|
for k,v in next,org do
|
||||||
if type(v)~='table'or depth==0 then
|
if type(v)=='table'and depth>0 then
|
||||||
L[k]=v
|
|
||||||
else
|
|
||||||
L[k]=TABLE.copy(v,depth-1)
|
L[k]=TABLE.copy(v,depth-1)
|
||||||
|
else
|
||||||
|
L[k]=v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return L
|
return L
|
||||||
|
|||||||
Reference in New Issue
Block a user