MathGroup Archive 1998

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

Search the Archive

Re: Re: Is this a bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13485] Re: Re: Is this a bug?
  • From: "Allan Hayes" <hay at haystack.demon.cc.uk>
  • Date: Sun, 26 Jul 1998 02:33:44 -0400
  • References: <6p97ac$b5u@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

jfreeze at lexmark.com wrote in message <6p97ac$b5u at smc.vnet.net>...
>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.

Jim:

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
>converting
>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
ToExpression?
Is "invalid expression" standing in for something? I ask because of

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

------------------------------------------------------------- 
Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
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!