MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

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: mail2news@nym.alias.net
  • References: <6vuqqn$8jq@smc.vnet.net>
  • 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


  • Prev by Date: Re: Mathematica 3 speed on a Sun Ultra1/200e ?
  • Next by Date: Strange results
  • Previous by thread: SOme problems with "Save"
  • Next by thread: MATHEMATICA COURSE BY PROF.DR. FRED SIMONS