Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

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/


  • Prev by Date: Re: Palettes in 2.2 ?
  • Next by Date: Re: multi-dim integration
  • Previous by thread: Re: Palettes in 2.2 ?
  • Next by thread: Re: Problem with Conditiond Function