Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Deepcopy/Lingo/deepcopy-1.lingo
Normal file
19
Task/Deepcopy/Lingo/deepcopy-1.lingo
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
-- Supports lists, property lists, images, script instances and scalar values (integer, float, string, symbol).
|
||||
on deepcopy (var, cycleCheck)
|
||||
case ilk(var) of
|
||||
#list, #propList, #image:
|
||||
return var.duplicate()
|
||||
#instance:
|
||||
if string(var) starts "<Xtra " then return var -- deep copy makes no sense for Xtra instances
|
||||
if voidP(cycleCheck) then cycleCheck = [:]
|
||||
if not voidP(cycleCheck[var]) then return cycleCheck[var]
|
||||
copy = var.script.rawNew()
|
||||
cycleCheck[var] = copy
|
||||
repeat with i = 1 to var.count
|
||||
copy.setProp(var.getPropAt(i), deepcopy(var[i], cycleCheck))
|
||||
end repeat
|
||||
return copy
|
||||
otherwise:
|
||||
return var
|
||||
end case
|
||||
end
|
||||
8
Task/Deepcopy/Lingo/deepcopy-2.lingo
Normal file
8
Task/Deepcopy/Lingo/deepcopy-2.lingo
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
val = [#foo:42, "bar":[1,2,3, "Hello world!"]]
|
||||
put deepcopy(val)
|
||||
-- [#foo: 42, "bar": [1, 2, 3, "Hello world!"]]
|
||||
|
||||
val = script("MyClass").new()
|
||||
val.foo = 42
|
||||
val.bar = [1, 2, 3, "Hello world!"]]
|
||||
copy = deepcopy(val)
|
||||
Loading…
Add table
Add a link
Reference in a new issue