MathGroup Archive 2007

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

Search the Archive

Re: Single-step evaluation in Mathematica


On 18 Sep 2007, at 01:07, Szabolcs Horv=E1t wrote:

> On 17/09/2007, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote:
>> SetAttributes[f, HoldAll]
>> f[x_String] := ValueQ @@ ToExpression[x, InputForm, Hold]
>
> Thank you for the reply!  This solution works perfectly (HoldAll isn't
> even needed)!

You are right, of course. I originally intended to define f both for 
strings symbols expressions but forgot about the latter:

SetAttributes[f, HoldAll]
f[x_String] := ValueQ @@ ToExpression[x, InputForm, Hold]
f[x_Symbol]:=ValueQ[x]

Andrzej


> The missing piece was the third argument of
> ToExpression[].  I have always thought that ToExpression[] takes only
> a single argument---I should check the documentation more often.  I
> tried using Symbol[] too, which, according to the documentation,
> should "refer to a symbol with the specified name".  But it turns out
> that Symbol["abc"] does not _refer_ to the symbol 'abc'; it simply
> _evaluates to_ 'abc'.  For example, Symbol["abc"] = 1 does not work.
>
> Szabolcs



  • Prev by Date: Fitting parameters of nonlinear diff equation system
  • Next by Date: Is RealTime3D back?
  • Previous by thread: Single-step evaluation in Mathematica
  • Next by thread: Re: Single-step evaluation in Mathematica