Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1570 > unrolled thread

Question on TraceScan

Started byAlexey <lehin.p@gmail.com>
First post2011-04-09 11:28 +0000
Last post2011-04-09 11:28 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Question on TraceScan Alexey <lehin.p@gmail.com> - 2011-04-09 11:28 +0000

#1570 — Question on TraceScan

FromAlexey <lehin.p@gmail.com>
Date2011-04-09 11:28 +0000
SubjectQuestion on TraceScan
Message-ID<inpftp$9ak$1@smc.vnet.net>
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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web