Re: TraceScan
- To: mathgroup at smc.vnet.net
- Subject: [mg63710] Re: TraceScan
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 10 Jan 2006 04:50:36 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <dpvmlr$lua$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Chris Rodgers wrote: > Hi, > > I can't seem to get TraceScan to work. Can someone explain why this > TraceScan command produces only a single line of output (with no > intermediate steps in evaluation) whereas the later Trace and TracePrint > examples show several steps? > > Doesn't seem to work: > > In[94]:= > TraceScan[InputForm,f[x+y+2+3]] > > Out[94]= > f[5+x+y] > > Produces intermediate steps: > > In[95]:= > Trace[f[x+y+2+3]] > > Out[95]= > {{x+y+2+3,5+x+y},f[5+x+y]} > > So does this: > > In[96]:= > TracePrint[f[x+y+2+3]] > > From In[96]:= > \[InvisibleSpace]f[x+y+2+3] > > From In[96]:= > \[InvisibleSpace]f > > From In[96]:= > \[InvisibleSpace]x+y+2+3 > > From In[96]:= > \[InvisibleSpace]Plus > > From In[96]:= > \[InvisibleSpace]x > > From In[96]:= > \[InvisibleSpace]y > > From In[96]:= > \[InvisibleSpace]2 > > From In[96]:= > \[InvisibleSpace]3 > > From In[96]:= > \[InvisibleSpace]5+x+y > > From In[96]:= > \[InvisibleSpace]Plus > > From In[96]:= > \[InvisibleSpace]5 > > From In[96]:= > \[InvisibleSpace]x > > From In[96]:= > \[InvisibleSpace]y > > From In[96]:= > \[InvisibleSpace]f[5+x+y] > > Out[96]= > f[5+x+y] > > Many thanks, > > Chris. > Hi Chris, TraceScan works fine indeed. The result you get depends on your choice of function as first argument. For example In[1]:= TraceScan[Print[TraditionalForm[#]]&,f[x+y+2+3]] From In[1]:= f(x+y+3+2) From In[1]:= f From In[1]:= x+y+3+2 From In[1]:= Plus From In[1]:= x From In[1]:= y From In[1]:= 2 From In[1]:= 3 From In[1]:= x+y+5 From In[1]:= Plus From In[1]:= 5 From In[1]:= x From In[1]:= y From In[1]:= f(x+y+5) Out[1]= f[5+x+y] Best regards, /J.M.