Steve Wampler wrote: > To partially answer my own question, having just read the paragraph following > the code: one thing it doesn't handle properly are self-referential structures > (e.g. cyclic graphs). Nor does it correctly handle multi-linked structures > (e.g. acyclic graphs with shared nodes).
How about this? ---------------------------------------- #<p> # deepcopy(A) -- make a full copy of the object A, including # any referenced objects - derived from deepcopy() version # given in the Unicon book. #</p> procedure deepcopy(A,cache) local k /cache := table() # used to handle multi-referenced objects if \cache[A] then return cache[A] case type(A) of { "table"|"list"|"record": { cache[A] := copy(A) every cache[A][k := key(A)] := deepcopy(A[k], cache) } "set": { cache[A] := set() every insert(cache[A], deepcopy(!A, cache)) } default: return A } return .cache[A] end -------------------------------------------------------- -- Steve Wampler -- [EMAIL PROTECTED] The gods that smiled on your birth are now laughing out loud. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Unicon-group mailing list Unicon-group@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/unicon-group