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 1998

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

Search the Archive

Re: Protecting from evaluation

  • To: mathgroup at
  • Subject: [mg14665] Re: Protecting from evaluation
  • From: "David Bailey" <db at>
  • Date: Sat, 7 Nov 1998 02:10:20 -0500
  • Organization: Salford
  • References: <71jl01$>
  • Sender: owner-wri-mathgroup at

William B. Marks wrote in message <71jl01$8m7 at>...
>To display variable names along with their values I can put them in
>quotes first using
>quote[var_] := ToString[var]
>Then this works
>quote[Unevaluated @ cVWGL]
>but this fails
>but since this fails
>Unevaluated /@ {cVThGL, cVWGL}
>{Unevaluated[900], Unevaluated[20.]}
>I can't see a way to protect members of a list of variables except by
>putting quotes around them by hand. Any suggestions?

> I can't see a way to protect members of a list of variables except by
> putting quotes around them by hand. Any suggestions?

First, your 'quote' function can be written so you do not need to wrap
its argument in 'Unevaluated' each time you use it. The problem with
the function
as you wrote it is that although the argument is not evaluated on the
call to
'quote', it is still evaluated when you call 'ToString' - so you are no
forward! The answer is either to temporarily remove its value, e.g.
using the 'Block'

SetAttributes[quote,HoldAllComplete]; quote[var_] :=

or to use HoldForm:

SetAttributes[quote,HoldAllComplete]; quote[var_] :=

When you write Unevaluated /@ {cVThGL, cVWGL} it is important to realise
that the
/@ operator invokes the 'Map' function, which evaluates its

The following function will apply 'quote' to a list without evaluating


As you can see, manipulating unevaluated expressions is rather subtle
and I usually recommend that people avoid giving their algebraic
variables explicit
values. For example, instead of setting cVWGL to 20, you could save this
in a list of transformation rules (stored in a variable) and apply this
you needed to map from variables to values.

David Bailey
Salford Software
db at

  • Prev by Date: Re: Abs and derivative problems
  • Next by Date: How to transpose vector?
  • Previous by thread: Re: Protecting from evaluation
  • Next by thread: Re: Protecting from evaluation