AbsoluteLevel again
- To: mathgroup@smc.vnet.net
- Subject: [mg10577] AbsoluteLevel again
- From: "Arturas Acus" <acus@itpa.lt>
- Date: Tue, 20 Jan 1998 16:54:17 -0500
Hello,
Thanks to everybody who suggested solutions for AbsoluteLevel.
Unfortunatelly, I did not manage to express want I actually want. Here
is one more try.
I define a function:
foo[a_,b_]:=bar[a,b]/;(FindAbsoluteLevel[a]<2)
Where "FindAbsoluteLevel "
, as Daniel Lichtblau noted, is a nesting-depth-counter in respect to
outermost level of evaluation at that particular moment, when pattern
matching occurs. (of course pattern matching occurs at some Level. I
only want to KNOW at which Level it sits at that moment)
When applied to :
foo[a,b[foo[c,d]]]
I want the the following substitution take place
bar[a,b[foo[c,d]]]
because only "a" is at Level one:
Level[foo[a,b[foo[c,d]]],1]
Out[10]=
{a,b[foo[c,d]]}
I suspect (as Dave Withoff noted) that I could never use this
FindAbsoluteLevel if I climb to the outermost Level. So is it
possible to have such a function? Can I know evaluation level at the
moment without evaluation the whole expression? Actually I want to
return to the point of evaluation after checking condition.
I want to note that there is no probllem at all to replace inner foo[]:
simply check FreeQ[]. I want to replace outermost foo[] and associate
the replacemant rule with name foo!
Arturas Acus
Institute of Theoretical
Physics and Astronomy
Gostauto 12, 2600,Vilnius
Lithuania
E-mail: acus@itpa.lt
Fax: 370-2-225361
Tel: 370-2-612906