Problem with Conditiond Function
- To: mathgroup at smc.vnet.net
- Subject: [mg7875] Problem with Conditiond Function
- From: hans.steffani at e-technik.tu-chemnitz.de (Hans Steffani)
- Date: Thu, 17 Jul 1997 15:35:39 -0400
- Organization: University of Technology Chemnitz, FRG
- Sender: owner-wri-mathgroup at wolfram.com
I have problems with the code below. foo[ Inverse[T11], Scalars->{T11} ] should produce 1/T11. This is ok but ofter foo[] is called the first time Inverse[T11] is always evaluated to 1/T11 which is not what I want and further calls of foo[] fail. What am I doing wrong? Hans Friedrich Steffani --snip--snap-- (* I Hope that the Rule will tested every time *) Unprotect[Inverse]; Inverse[m_] := 1/m /; MemberQ[$theScalars,m]; Protect[Inverse]; (* And this is the function which tells what are $theScalars is *) foo[expr_,opt:Scalars->theScalars_List]:= Module[{}, Unprotect[Inverse]; $theScalars := theScalars; expr = expr; Clear[ $theScalars ]; Protect[Inverse]; expr ] Inverse[T11] (* ok *) foo[ Inverse[T11], Scalars->{T11} ] (* ok *) Inverse[T11] (* why Do I get 1/T *) foo[ Inverse[T11], Scalars->{T11} ] (* fails with error *) --snip--snap-- -- Hans Friedrich Steffani Institut fuer Elektrische Maschinen und Antriebe, TU Chemnitz-Zwickau mailto:hans.steffani at e-technik.tu-chemnitz.de http://www.tu-chemnitz.de/~hfst/