Copy := proc (x) options `Maple Advisor Database 1.01 for Maple 6`, `Copyright (c) 2000 by Robert B. Israel. All rights reserved`; local dummy, rec, res, RT, Ind, Ent, k, locs, exps, locv, expv, S,first,l,i,j; rec:= (nargs > 1) and (args[2]='recursive'); if type(x,procedure) then subs(dummy = dummy, eval(x)) elif type(x,`module`) then exps:= op(1,eval(M)); expv:= map(t -> [`tools/gensym`(t),eval(t)],[exps]); locs:= op(3,eval(M)); locv:= map(t -> [`tools/gensym`(t),eval(t)],[locs]); S:= "module() "; if nops([locv]) <> NULL then S:= cat(S,"local "); first:= true; for l in locv do if not first then S:= cat(S,", ") fi; S:= cat(S,l[1]); first:= false; od; S:= cat(S,"; "); fi; if nops([expv]) <> NULL then S:= cat(S,"export "); first:= true; for l in expv do if not first then S:= cat(S,", ") fi; S:= cat(S,l[1]); first:= false; od; S:= cat(S,"; "); fi; for i from 1 to nops(expv) do S:= cat(S,expv[i][1],":="); if nops(expv[i]) = 1 then S:= cat(S," NULL; ") else for j from 2 to nops(expv[i]) do S:= cat(S,convert(expv[i][j],string), `if`(j NULL then Ind:= [indices(RT)]; Ent:= [entries(RT)]; for k from 1 to nops(Ind) do S:= cat(S,expv[i][1],"(",convert(op(Ind[k]),string), "):= ",convert(op(Ent[k]),string),";"); od; fi fi fi; od; for i from 1 to nops(locv) do S:= cat(S,locv[i][1],":="); if nops(locv[i]) = 1 then S:= cat(S," NULL; ") else for j from 2 to nops(locv[i]) do if rec then locv[i][j]:= Copy(locv[i][j]) fi; S:= cat(S,convert(locv[i][j],string), `if`(j NULL then Ind:= [indices(RT)]; Ent:= [entries(RT)]; for k from 1 to nops(Ind) do S:= cat(S,locv[i][1],"(",convert(op(Ind[k]),string), "):= ",convert(op(Ent[k]),string),";"); od; fi fi fi; od; eval(parse(cat(S," end"))) elif type(x,rtable) then if rec then LinearAlgebra:-Map(Copy,rtable(rtable_indfns(x),x),'recursive'); else rtable(rtable_indfns(x),x,rtable_options(x)) fi elif type(x,table) then if rec then map(Copy,eval(x),'recursive') else map(proc () args end proc,eval(x)) fi elif type(x,atomic) then x else map(Copy,args) end if end proc;