Re: Problem with HoldForm & Unevaluated
- To: mathgroup at smc.vnet.net
- Subject: [mg94498] Re: Problem with HoldForm & Unevaluated
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Mon, 15 Dec 2008 07:43:03 -0500 (EST)
- References: <gi2umq$9vg$1@smc.vnet.net>
Hi,
> A simple example;
>
> printf[fn_] := Print[HoldForm[fn], " = ", fn];
>
> printf[Rationalize /@ {-1.7, 1.39646, -0.37188}]
>
> Print[HoldForm[Rationalize /@ {-1.7, 1.39646, -0.37188}], " = ",
> Rationalize /@ {-1.7, 1.39646, -0.37188}]
>
> gives the LHS evaluated:
>
> {-(17/10),69823/50000,-(9297/25000)} = {-(17/10),69823/50000,-
> (9297/25000)}
>
> Instead of the hoped for output:
>
> Rationalize/@{-1.7,1.39646,-0.37188} = {-(17/10),69823/50000,-
> (9297/25000)}
>
> Using Unevaluated seemed to me should fix it but does not.
Use this:
SetAttributes[printf, HoldFirst]
along with your above expression. It has the same effect as wrapping the
argument with Unevaluated, but you don't need to type it...
hth,
albert