RE: Can Mathematica evaluate step by step???
- To: mathgroup at smc.vnet.net
- Subject: [mg29387] RE: [mg29372] Can Mathematica evaluate step by step???
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 16 Jun 2001 02:47:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Neri, It would be interesting to know what your larger objective is. A different Mathematica approach is probably the answer to your problem. Once you set a value for a, you have to use rather round about methods to keep it from being evaluated. So my first suggestion would be: don't set a to a value if you intend to later use it as a variable. You could do something like this (although I doubt that this is the answer you are looking for) a = 4; myfunction[a_] := 2a HoldForm @@ {myfunction[b]} % /. b :> a 2 b 2 a But what use would that result be for you, since it is in a HoldForm? So I think that you must avoid setting values for anything you want to use as a symbolic variable. It is often better to use rules, a -> 4, to substitute values for variables, or myfunction[4] to evaluate at a specific value. In my work I follow my own rule of never setting a single character symbol (a,b,x,y, etc.) to a value. The chances of getting tripped up by it are just too high. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Neri Kafkafi [mailto:NKafkafi at intra.nida.nih.gov] To: mathgroup at smc.vnet.net > > Assume I define: > myfunction:=2a > > and at some later time: > a=4 > > Now if I evaluate myfunction I get 8. > If I evaluate Hold[myfunction] I get myfunction. > > My question is, how do I get 2a ? > > In other words, I want to get the symbolic definition of > myfunction, whether > a is defined or not. > > In (yet) other words, I want to evaluate myfunction only one step further, > up to 2a, but not all the way to 8. > > Is this possible in Mathematica? > > Thanks in advance, > Neri > > > > >