MathGroup Archive 2011

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

Search the Archive

Question on TraceScan

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118036] Question on TraceScan
  • From: Alexey <lehin.p at gmail.com>
  • Date: Sat, 9 Apr 2011 07:28:44 -0400 (EDT)

Good day,

I have some questions regarding TraceScan.

1.) Why TraceScan does not give the final expression f[a, 1] in this
case while Trace gives:

In[1]:= SetAttributes[traceScan,HoldAll];
traceScan[expr_]:=(list={};TraceScan[AppendTo[list,#]&,expr];list)
In[3]:= ClearAll[f,a];
Trace[f[a,1],TraceOriginal->True]
Out[4]= {f[a,1],{f},{a},{1},f[a,1]}
In[5]:= ClearAll[f,a];
traceScan[f[a,1]]
Out[6]= {f[a,1],f,a,1}

2.) And why in the following case both Trace and TraceScan give the
final expression f[1, a] but only Trace gives intermediate expression
f[a, 1]:

In[7]:= ClearAll[f,a];
SetAttributes[f,Orderless]
Trace[f[a,1],TraceOriginal->True]
Out[9]= {f[a,1],{f},{a},{1},f[a,1],f[1,a]}
In[12]:= ClearAll[f,a];
SetAttributes[f,Orderless]
traceScan[f[a,1]]
Out[14]= {f[a,1],f,a,1,f[1,a]}

3.) And why in this last case both Trace and TraceScan give the final
expression ff[1, b] and the intermadiate expression ff[b, 1]:

In[21]:= ClearAll[f,ff,a];
SetAttributes[{f,ff},Orderless];f=ff;a=b;
Trace[f[a,1],TraceOriginal->True]
Out[23]= {f[a,1],{f,ff},{a,b},{1},ff[b,1],ff[1,b]}
In[24]:= ClearAll[f,ff,a];
SetAttributes[{f,ff},Orderless];f=ff;a=b;
traceScan[f[a,1]]
Out[26]= {f[a,1],f,ff,a,b,1,ff[b,1],ff[1,b]}

4.) Is there a way to force TraceScan always give exhaustive
information about evaluation as Trace does?

Alexey


  • Prev by Date: Re: CDF browser plugin and Wolfram library archive
  • Next by Date: Re: Normalize[] gives incorrect answer for some norm functions
  • Previous by thread: Re: Managing your notebooks
  • Next by thread: Wolfram Library Archive: resume-able downloading of files