Deepcopy: Difference between revisions
Content added Content deleted
Line 616: | Line 616: | ||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
<lang lingo>-- Supports lists, property lists, images, script instances and scalar values (integer, float, string, symbol). |
<lang lingo>-- Supports lists, property lists, images, script instances and scalar values (integer, float, string, symbol). |
||
⚫ | |||
-- Does not support cyclic references (objects having themselves as property) |
|||
⚫ | |||
case ilk(var) of |
case ilk(var) of |
||
#list, #propList, #image: |
#list, #propList, #image: |
||
return var.duplicate() |
return var.duplicate() |
||
#instance: |
#instance: |
||
if voidP(cycleCheck) then cycleCheck = [:] |
|||
if not voidP(cycleCheck[var]) then return cycleCheck[var] |
|||
copy = var.script.rawNew() |
copy = var.script.rawNew() |
||
cycleCheck[var] = copy |
|||
repeat with i = 1 to var.count |
repeat with i = 1 to var.count |
||
copy.setProp(var.getPropAt(i), deepcopy(var[i])) |
copy.setProp(var.getPropAt(i), deepcopy(var[i], cycleCheck)) |
||
end repeat |
end repeat |
||
return copy |
return copy |
||
Line 630: | Line 632: | ||
return var |
return var |
||
end case |
end case |
||
end |
end |
||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |