MathGroup Archive 2007

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

Search the Archive

Re: Single-step evaluation in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81277] Re: [mg81235] Single-step evaluation in Mathematica
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 18 Sep 2007 00:42:27 -0400 (EDT)
  • References: <200709170732.DAA15466@smc.vnet.net> <96D69218-954A-4705-8EA8-8B79B44D9BDA@mimuw.edu.pl> <f831b3d60709170907v1635cdbcj4ed6e4e620bf80d5@mail.gmail.com>

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