Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1570
| From | Alexey <lehin.p@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Question on TraceScan |
| Date | 2011-04-09 11:28 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <inpftp$9ak$1@smc.vnet.net> (permalink) |
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
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Question on TraceScan Alexey <lehin.p@gmail.com> - 2011-04-09 11:28 +0000
csiph-web