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: [mg19519] Re: ReplaceAll in If Statement
  • From: Brian Higgins <bghiggins at>
  • Date: Sun, 29 Aug 1999 03:00:39 -0400
  • Organization: - Share what you know. Learn what you don't.
  • References: <7q20sl$>
  • Sender: owner-wri-mathgroup at

In article <7q20sl$q9i at>,
  "Tom Compton" <comptont at> wrote:
> 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}]
The pesky problem is the pair of braces in the condition test:
a /. {opts}. Replace with a/.opts. With your expression, the output from
the replacement function is "{True}" instead of the required "True"

Regards Brian
> In[3]:=
> test[opList]
> Out[3]=
> {{True,3}}
> Tom Compton

Sent via
Share what you know. Learn what you don't.

  • Prev by Date: Sqrt problems
  • Next by Date: Re: getting rid of TraditionalForm
  • Previous by thread: Re: ReplaceAll in If Statement
  • Next by thread: Quick Question: Get part of the plot