Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: ReplaceAll in If Statement

  • To: mathgroup at
  • Subject: [mg19472] Re: [mg19448] ReplaceAll in If Statement
  • From: "Mark E. Harder" <harderm at>
  • Date: Sat, 28 Aug 1999 15:53:03 -0400
  • Sender: owner-wri-mathgroup at

        You have inadvertently (I think) nested your rule too deeply by
making opList a list, then enclosing it in {} in the rule application.
While a/. {(a->True)} becomes a=True, a/.{{a->True}} evaluates to neither t
nor f, so the If[] returns z=3. The following is what you want:


If[a /. {opts}, z=1, z=2, z=3];
{a, z} /. {opts}]




-----Original Message-----
From: Tom Compton <comptont at>
To: mathgroup at
Subject: [mg19472] [mg19448] ReplaceAll in If Statement

>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?
>If[a /. {opts}, z=1, z=2, z=3];
>{a, z} /. {opts}]
>Tom Compton

  • Prev by Date: Finite Element Method and Mathematica
  • Next by Date: Re: ReplaceAll in If Statement
  • Previous by thread: Re: ReplaceAll in If Statement
  • Next by thread: Re: ReplaceAll in If Statement