2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
25
Task/Deepcopy/Lua/deepcopy-1.lua
Normal file
25
Task/Deepcopy/Lua/deepcopy-1.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
function _deepcopy(o, tables)
|
||||
|
||||
if type(o) ~= 'table' then
|
||||
return o
|
||||
end
|
||||
|
||||
if tables[o] ~= nil then
|
||||
return tables[o]
|
||||
end
|
||||
|
||||
local new_o = {}
|
||||
tables[o] = new_o
|
||||
|
||||
for k, v in next, o, nil do
|
||||
local new_k = _deepcopy(k, tables)
|
||||
local new_v = _deepcopy(v, tables)
|
||||
new_o[new_k] = new_v
|
||||
end
|
||||
|
||||
return new_o
|
||||
end
|
||||
|
||||
function deepcopy(o)
|
||||
return _deepcopy(o, {})
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue