Re: SOme problems with "Save"
- To: mathgroup at smc.vnet.net
- Subject: [mg14372] Re: SOme problems with "Save"
- From: Timothy Culver <Use-Author-Address-Header at [127.1]>
- Date: Thu, 15 Oct 1998 00:29:11 -0400
- Author-address: culver <AT> cs <DOT> unc <DOT> edu
- Organization: email@example.com
- References: <firstname.lastname@example.org>
- Sender: owner-wri-mathgroup at wolfram.com
In article <6vuqqn$8jq at smc.vnet.net>, Gadi Oron <oron at manet.pmmh.espci.fr> wrote: >Hi, > >When saving a definition, Mathematica attaches all linked definitions, >which is normal; [...] > >Here also, FullDefinition is wrong thinking the global definition of x >is needed in the function f. > >Any idea how to correct this problem? I don't have a general solution, but here's the trick I use. I think it works for both of your examples. SaveOnly[ostream_,expr_] := Write[ostream, OutputForm[ToString[Unevaluated[expr]]<>" = "], expr] SetAttributes[SaveOnly, HoldRest] f[z_]:=1+z z=1 (* Global variable *) ostr=OpenWrite["foo"] SaveOnly[ostr,DownValues[f]] Close[ostr]; This saves all the definitions of f in DownValues format. Then, later, typing <<foo will reset the definition of `f' to the way it was when you saved it. -- Tim Culver