MathGroup Archive 1998

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

Search the Archive

Re: How to use HoldForm within Module

  • To: mathgroup at
  • Subject: [mg15276] Re: How to use HoldForm within Module
  • From: "Allan Hayes" <hay at>
  • Date: Thu, 31 Dec 1998 04:39:31 -0500
  • References: <76cijv$>
  • Sender: owner-wri-mathgroup at

Chee Lim Cheung wrote in message <76cijv$o48 at>...
>Hello Mathematica gurus,
>I am new to Mathematica. I need to use a function in its original form
>within Module.
>may not give what I want as f is already rearranged according to
>Mathematica's lexicographical order within Module,i.e.,HoldForm[f] in
>Module may not be exactly of the same form as f as defined. One example
>is f=-1(UnitStep[t-1]-UnitStep[t-2]).Can any of you out there show me
>the way to get f in its original form inside Module?

In your code, the function f is evaluated before being passed to the
right side.
This can be prevented by giving doNOTCHANGE the attribute HoldAll:

Attributes[doNOTCHANGE] = HoldAll;

doNOTCHANGE[f_] := Module[{g}, g = HoldForm[f]; Print[g]]

doNOTCHANGE[1(UnitStep[t - 1] - UnitStep[t - 2])]

    1 (UnitStep[t - 1] - UnitStep[t - 2])

If you don't need the Module then

Attributes[doNOTCHANGE2] = HoldAll;

doNOTCHANGE2[f_] := Print[HoldForm[f]]

doNOTCHANGE2[1(UnitStep[t - 1] - UnitStep[t - 2])]

1 (UnitStep[t - 1] - UnitStep[t - 2])


Allan Hayes
Mathematica Training and Consulting
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

  • Prev by Date: Cell Bracket Notation
  • Next by Date: A question on viewing 3D Graphics
  • Previous by thread: RE: How to use HoldForm within Module
  • Next by thread: mathlink program hanging in MLAnswer