Re: Problem with HoldForm & Unevaluated
- To: mathgroup at smc.vnet.net
- Subject: [mg94525] Re: Problem with HoldForm & Unevaluated
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Mon, 15 Dec 2008 07:48:00 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <gi2umq$9vg$1@smc.vnet.net>
Syd Geraghty wrote:
> Hi all,
>
> A seemingly simple function has me baffled and I would appreciate a
> solution.
>
> I am trying to define a personal print function that prints
> "Unevaluated function string" = Evaluated function!
>
> I have tried many examples in guide/EvaluationControl documentation
> without getting what I want.
>
> 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.
>
> Thanks in advance for your help.
>
> Cheers ... Syd
>
> PS I've tried Mathematica 5.2 as well as 7.0
>
>
>
> Syd Geraghty B.Sc, M.Sc.
>
> sydgeraghty at mac.com
>
> Mathematica 7.0.0 for Mac OS X x86 (64 - bit) (21st November, 2008)
> MacOS X V 10.5.4
> MacBook Pro 2.33 Ghz Intel Core 2 Duo 2GB RAM
Syd,
FWIW, I am clueless about where the problem lies on your systems, but I
have got the expected result/behavior on two different platforms (6.0.3
on 64-bit Mac OS X 10.5.5 and 7.0 on 32-bit Windows XP Pro SP3).
In[1]:= Print[
HoldForm[Rationalize /@ {-1.7, 1.39646, -0.37188}], " = ",
Rationalize /@ {-1.7, 1.39646, -0.37188}]
During evaluation of In[1]:= Rationalize/@{-1.7,1.39646,-0.37188} = \
{-(17/10),69823/50000,-(9297/25000)}
In[2]:= HoldForm[Rationalize /@ {-1.7, 1.39646, -0.37188}] ==
Rationalize /@ {-1.7, 1.39646, -0.37188}
Out[2]=
Rationalize/@{-1.7,1.39646,-0.37188}=={-(17/10),69823/50000,-(9297/25000)}
In[3]:= $Version
Out[3]= "6.0 for Mac OS X x86 (64-bit) (May 21, 2008)"
In[1]:= Print[
HoldForm[Rationalize /@ {-1.7, 1.39646, -0.37188}], " = ",
Rationalize /@ {-1.7, 1.39646, -0.37188}]
During evaluation of In[1]:= Rationalize/@{-1.7,1.39646,-0.37188} =
{-(17/10),69823/50000,-(9297/25000)}
In[2]:= HoldForm[Rationalize /@ {-1.7, 1.39646, -0.37188}] ==
Rationalize /@ {-1.7, 1.39646, -0.37188}
Out[2]=
Rationalize/@{-1.7,1.39646,-0.37188}=={-(17/10),69823/50000,-(9297/25000)}
In[3]:= $Version
Out[3]= "7.0 for Microsoft Windows (32-bit) (November 10, 2008)"
Regards,
-- Jean-Marc