Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Unevaluated Expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26962] Unevaluated Expression
  • From: "Hermann Meier" <hmeier at webshuttle.ch>
  • Date: Tue, 30 Jan 2001 03:38:15 -0500 (EST)
  • Organization: EUnet AG, Switzerland. A KPNQwest Company.
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Mathematica users,

a = 10;
Unprotect[ToString]; SetAttributes[ToString, HoldAll]
ToString[a]//FullForm
gives (as desired) "a", not 10


Then I wanted to prevent the argument in f[x_] := x^2  from
getting evaluated.

Attributes[f] = {HoldAll}
f[x_] := x^2
f[Unevaluated[a]]
gives 100.

The longwinded code
ToExpression[ToString[f[a]], InputForm, Hold] /. Hold[f[nr_]] -> nr
or
First[Level[Composition[Hold][f[#]],{-1}]]& /@ {a,10}

at least manages to give 10 instead of 100.

Is there really no way to prevent the argument in f[x] from firing ?
(I use Mathematica 4.1 for Windows).


With best regards
Hermann Meier










  • Prev by Date: Saving notebooks without graphics
  • Next by Date: Want to use results by Parallel Computing
  • Previous by thread: RE: Saving notebooks without graphics
  • Next by thread: Re: Unevaluated Expression