MathGroup Archive 1999

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

Search the Archive

Re: ReplaceAll in If Statement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19489] Re: ReplaceAll in If Statement
  • From: Eckhard Hennig <hennig at itwm.uni-kl.de>
  • Date: Sat, 28 Aug 1999 15:53:13 -0400
  • Organization: ITWM
  • References: <7q20sl$q9i@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Tom Compton schrieb in Nachricht <7q20sl$q9i at smc.vnet.net>...
>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,

note that your function call in In[3] evaluates to 

  test[{a->True}],

but what you wanted is

  test[a->True],

i.e. the argument to test must be a Sequence of rules, not a List. With

  test @@ opList

your function works correctly.

-- Eckhard

-----------------------------------------------------------
Dipl.-Ing. Eckhard Hennig      mailto:hennig at itwm.uni-kl.de
Institut fuer Techno- und Wirtschaftsmathematik e.V. (ITWM)
Erwin-Schroedinger-Strasse,  67663 Kaiserslautern,  Germany
  Voice: +49-(0)631-205-3126    Fax: +49-(0)631-205-4139
    http://www.itwm.uni-kl.de/as/employees/hennig.html

     ITWM - Makers of Analog Insydes for Mathematica
        http://www.itwm.uni-kl.de/as/products/ai
-----------------------------------------------------------





  • Prev by Date: Stochastic Differentail equations
  • Next by Date: Re: Behavior of Array[]
  • Previous by thread: Re: ReplaceAll in If Statement
  • Next by thread: Re: ReplaceAll in If Statement