Re: ReplaceAll in If Statement

*To*: mathgroup at smc.vnet.net*Subject*: [mg19462] Re: [mg19448] ReplaceAll in If Statement*From*: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>*Date*: Sat, 28 Aug 1999 15:52:58 -0400*Sender*: owner-wri-mathgroup at wolfram.com

The problem is very simple. {True} is not the same as True. Change your definition od test to test[opts___] := Module[{}, If[a /. opts, z = 1, z = 2, z = 3]; {a, z} /. opts] and you will get the behaviour you expected: In[10]:= test[opList] Out[10]= {True, 1} -- Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp http://eri2.tuins.ac.jp ---------- >From: "Tom Compton" <comptont at concentric.net> To: mathgroup at smc.vnet.net >To: mathgroup at smc.vnet.net >Subject: [mg19462] [mg19448] ReplaceAll in If Statement >Date: Wed, Aug 25, 1999, 6:25 AM > > In the following sequence I expected z to evaluate to 1 in the > Module. It appears that the test in the module does not > evaluate to either True or False. I don't understand why. > Can anyone explain? > > In[1]:= > opList={a->True}; > > In[2]:= > test[opts___]:=Module[{}, > If[a /. {opts}, z=1, z=2, z=3]; > {a, z} /. {opts}] > > In[3]:= > test[opList] > Out[3]= > {{True,3}} > > > > Tom Compton > > > >