Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14417 > unrolled thread

Text based interface: $PreRead does not work as manual says.

Started byAlain Cochard <Alain.Cochard@unistra.fr>
First post2013-05-06 06:25 +0000
Last post2013-05-08 08:09 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Text based interface: $PreRead does not work as manual says. Alain Cochard <Alain.Cochard@unistra.fr> - 2013-05-06 06:25 +0000
    Re: Text based interface: $PreRead does not work as manual says. Roland Franzius <roland.franzius@uos.de> - 2013-05-07 07:53 +0000
      Re: Text based interface: $PreRead does not work as manual says. alain cochard <al.1.cochard@gmail.com> - 2013-05-08 08:09 +0000

#14417 — Text based interface: $PreRead does not work as manual says.

FromAlain Cochard <Alain.Cochard@unistra.fr>
Date2013-05-06 06:25 +0000
SubjectText based interface: $PreRead does not work as manual says.
Message-ID<km7ic8$ic1$1@smc.vnet.net>
Here is an excerpt of
http://reference.wolfram.com/mathematica/ref/$PreRead.html

    Use as an alias for HoldForm:

    In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &

    Out[1]= #1 /. hf -> HoldForm & 

    In[2]:= {hf[2 + 3], hf[2/3]}

                  2
    Out[2]= {2+3, -]}
                  3

Using the text based interface, I try to reproduce the above:

    Mathematica 9.0 for Linux x86 (64-bit)
    Copyright 1988-2012 Wolfram Research, Inc.

    In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &

    Out[1]= #1 /. hf -> HoldForm & 

    In[2]:= {hf[2 + 3], hf[2/3]}

                       2
    Out[2]= {hf[5], hf[-]}
                       3

    In[3]:= hf

    Out[3]= hf

    In[4]:=?hf

    Global`hf


Other Mathematica version, other computer:

   Mathematica 8.0 for Linux x86 (32-bit)
   Copyright 1988-2011 Wolfram Research, Inc.

   In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &

   Out[1]= #1 /. hf -> HoldForm & 

   In[2]:= {hf[2 + 3], hf[2/3]}

                      2
   Out[2]= {hf[5], hf[-]}
                      3

   In[3]:= hf

   Out[3]= HoldForm <<<< so here it understands a litte bit...

And I get the same output as just above, with

   Mathematica 7.0 for Linux x86 (64-bit)
   Copyright 1988-2009 Wolfram Research, Inc.

on yet another computer.

However, it does work as expected when using the front end interface.

Is this normal?  

I spent some time in the documentation and on the web for an alternative
of $PreRead but did not find anything, apart from the obsolete "Alias"
Mathematica function; I found a documentation here:
http://reference.wolfram.com/legacy/v4-fr/OtherInformation/Alias_almark.html
I tried the simple example which is provided, but it does not react as
it should, neither with the text based nor the front end interfaces...

Is there something I can do to restore the correct behavior of $PreRead,
or use Alias, under the text based interface or is there an equivalent
way for defining such aliases?

Thanks in advance.
AC

-- 
EOST (École et Observatoire des Sciences de la Terre) 
IPG (Institut de Physique du Globe) | alain.cochard@unistra.fr
5 rue René Descartes   [bureau 106] | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France    | Fax:   +33 (0)3 68 85 01 25     

[toc] | [next] | [standalone]


#14434

FromRoland Franzius <roland.franzius@uos.de>
Date2013-05-07 07:53 +0000
Message-ID<kmabtp$qdf$1@smc.vnet.net>
In reply to#14417
Am 06.05.2013 08:25, schrieb Alain Cochard:
> Here is an excerpt of
> http://reference.wolfram.com/mathematica/ref/$PreRead.html
>
>      Use as an alias for HoldForm:
>
>      In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
>      Out[1]= #1 /. hf -> HoldForm &
>
>      In[2]:= {hf[2 + 3], hf[2/3]}
>
>                    2
>      Out[2]= {2+3, -]}
>                    3
>
> Using the text based interface, I try to reproduce the above:
>
>      Mathematica 9.0 for Linux x86 (64-bit)
>      Copyright 1988-2012 Wolfram Research, Inc.
>
>      In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
>      Out[1]= #1 /. hf -> HoldForm &
>
>      In[2]:= {hf[2 + 3], hf[2/3]}
>
>                         2
>      Out[2]= {hf[5], hf[-]}
>                         3
>
>      In[3]:= hf
>
>      Out[3]= hf
>
>      In[4]:=?hf
>
>      Global`hf
>
>
> Other Mathematica version, other computer:
>
>     Mathematica 8.0 for Linux x86 (32-bit)
>     Copyright 1988-2011 Wolfram Research, Inc.
>
>     In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
>     Out[1]= #1 /. hf -> HoldForm &
>
>     In[2]:= {hf[2 + 3], hf[2/3]}
>
>                        2
>     Out[2]= {hf[5], hf[-]}
>                        3
>
>     In[3]:= hf
>
>     Out[3]= HoldForm <<<< so here it understands a litte bit...
>
> And I get the same output as just above, with
>
>     Mathematica 7.0 for Linux x86 (64-bit)
>     Copyright 1988-2009 Wolfram Research, Inc.
>
> on yet another computer.
>
> However, it does work as expected when using the front end interface.
>
> Is this normal?
>
> I spent some time in the documentation and on the web for an alternative
> of $PreRead but did not find anything, apart from the obsolete "Alias"
> Mathematica function; I found a documentation here:
> http://reference.wolfram.com/legacy/v4-fr/OtherInformation/Alias_almark.html
> I tried the simple example which is provided, but it does not react as
> it should, neither with the text based nor the front end interfaces...
>
> Is there something I can do to restore the correct behavior of $PreRead,
> or use Alias, under the text based interface or is there an equivalent
> way for defining such aliases?


$Pre is working on the expression form of input, $PreRead on its input 
string form. enProcessing the string form of input into raw expression 
form, elemetary simplification by ordering takes place.

The lexicographic ordering of arithmetic expressions automatically 
performs counting equal subexpressions by implied attributed rules for 
Plus und Times like: OneIdentity, Flat and Orderless.

Consider the following

In[10]:= $PreRead :=
(ReplaceAll[#, {"+" :>  "-", "hf" -> "HoldForm"}] &)

In[11]:=
hf[a + 2 a]

Out[11]= \!\(\*TagBox[RowBox[{"a", "-",RowBox[{"2", " ", "a"}]}],
HoldForm]\)


-- 

Roland Franzius

[toc] | [prev] | [next] | [standalone]


#14454

Fromalain cochard <al.1.cochard@gmail.com>
Date2013-05-08 08:09 +0000
Message-ID<kmd18l$4j8$1@smc.vnet.net>
In reply to#14434
On May 7, 9:53 am, Roland Franzius <roland.franz...@uos.de> wrote:
> Am 06.05.2013 08:25, schrieb Alain Cochard:
>
>
>
> > Here is an excerpt of
> >http://reference.wolfram.com/mathematica/ref/$PreRead.html
>
> >      Use as an alias for HoldForm:
>
> >      In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
> >      Out[1]= #1 /. hf -> HoldForm &
>
> >      In[2]:= {hf[2 + 3], hf[2/3]}
>
> >                    2
> >      Out[2]= {2+3, -]}
> >                    3
>
> > Using the text based interface, I try to reproduce the above:
>
> >      Mathematica 9.0 for Linux x86 (64-bit)
> >      Copyright 1988-2012 Wolfram Research, Inc.
>
> >      In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
> >      Out[1]= #1 /. hf -> HoldForm &
>
> >      In[2]:= {hf[2 + 3], hf[2/3]}
>
> >                         2
> >      Out[2]= {hf[5], hf[-]}
> >                         3
>
> >      In[3]:= hf
>
> >      Out[3]= hf
>
> >      In[4]:=?hf
>
> >      Global`hf
>
> > Other Mathematica version, other computer:
>
> >     Mathematica 8.0 for Linux x86 (32-bit)
> >     Copyright 1988-2011 Wolfram Research, Inc.
>
> >     In[1]:= $PreRead = ReplaceAll[#, "hf" -> "HoldForm"] &
>
> >     Out[1]= #1 /. hf -> HoldForm &
>
> >     In[2]:= {hf[2 + 3], hf[2/3]}
>
> >                        2
> >     Out[2]= {hf[5], hf[-]}
> >                        3
>
> >     In[3]:= hf
>
> >     Out[3]= HoldForm <<<< so here it understands a litte bit...
>
> > And I get the same output as just above, with
>
> >     Mathematica 7.0 for Linux x86 (64-bit)
> >     Copyright 1988-2009 Wolfram Research, Inc.
>
> > on yet another computer.
>
> > However, it does work as expected when using the front end interface.
>
> > Is this normal?
>
> > I spent some time in the documentation and on the web for an alternative
> > of $PreRead but did not find anything, apart from the obsolete "Alias"
> > Mathematica function; I found a documentation here:
> >http://reference.wolfram.com/legacy/v4-fr/OtherInformation/Alias_alma...
> > I tried the simple example which is provided, but it does not react as
> > it should, neither with the text based nor the front end interfaces...
>
> > Is there something I can do to restore the correct behavior of $PreRead,
> > or use Alias, under the text based interface or is there an equivalent
> > way for defining such aliases?
>
> $Pre is working on the expression form of input, $PreRead on its input
> string form. enProcessing the string form of input into raw expression
> form, elemetary simplification by ordering takes place.
>
> The lexicographic ordering of arithmetic expressions automatically
> performs counting equal subexpressions by implied attributed rules for
> Plus und Times like: OneIdentity, Flat and Orderless.
>
> Consider the following
>
> In[10]:= $PreRead :=
> (ReplaceAll[#, {"+" :>  "-", "hf" -> "HoldForm"}] &)
>
> In[11]:=
> hf[a + 2 a]
>
> Out[11]= \!\(\*TagBox[RowBox[{"a", "-",RowBox[{"2", " ", "a"}]}],
> HoldForm]\)
>
> --
>
> Roland Franzius

Thanks for answering, and sorry that I do not understand what you are
saying.

At any rate, if I try your example, I do not get the same as you.


	Mathematica 7.0 for Linux x86 (64-bit)
	Copyright 1988-2009 Wolfram Research, Inc.

	In[1]:= $PreRead := (ReplaceAll[#, {"+" :>  "-", "hf" -> "HoldForm"}]
&)

	In[2]:= hf[a+2a]

	Out[2]= hf[3 a]

Again, I am using -- and insist on using -- the text based interface.

As far as I understand from the documentation
<http://reference.wolfram.com/mathematica/tutorial/
UsingATextBasedInterface.html>
the text based interface should provide the same capabilities as the
front end interface, except when it comes to graphics functionality
or dynamic interactivity, none of which being the case here.

AC

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web