MathGroup Archive 1998

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

Search the Archive

Re: Re: Is this a bug?

  • To: mathgroup at
  • Subject: [mg13485] Re: Re: Is this a bug?
  • From: "Allan Hayes" <hay at>
  • Date: Sun, 26 Jul 1998 02:33:44 -0400
  • References: <6p97ac$>
  • Sender: owner-wri-mathgroup at

jfreeze at wrote in message <6p97ac$b5u at>...
>Thanks for all of the responses. My original question was (basically)
>why does
>If[True, Evaluate[x=5], Evaluate[y=5]] give
>{x,y} as {5,5}.
>It was explained by several people that the reason is that Evaluate
>overides HoldRest.
>Nevertheless, it seems to me that expressions not returned from If
>should not be executed,
>regardless if Evaluate is used.


That would rule out using If to make assignments.

>I am looking for a solution to
>the following
>(seeing that If will not work now):
>If[ test, Evaluate[ToExpression["valid statement"]],
>Evaluate[ToExpression["invalid statement"]]]
>What this statement does it to test for validity of a string before
>it to an expression.
>Since If executes all its arguments, regardless of test, can someone
>suggest a
>method accomplish this task?

Depending on what test is you may need to convert the string to an
expression in order to test its validity. Subject to that, what about,
something like

If[ test, ToExpression["valid statement"], ToExpression["invalid
statement"], ToExpression["undecided statement"]]

Could you give a more explit example please? In particular, do you need
Is "invalid expression" standing in for something? I ask because of

ToExpression["invalid statement"]//FullForm Out[254]//FullForm=

Allan Hayes
Training and Consulting
Leicester UK
hay at
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642

  • Prev by Date: Deconvolution of Experimental Observations
  • Next by Date: Re: installing new packages in mathematica
  • Previous by thread: Re: Re: Is this a bug?
  • Next by thread: discrete math, how many zeroes in 125!