MathGroup Archive 2001

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

Search the Archive

Re: V4.1 Carriage Returns w/ ReplaceRepeated in Windows?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27630] Re: V4.1 Carriage Returns w/ ReplaceRepeated in Windows?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 9 Mar 2001 02:35:44 -0500 (EST)
  • References: <9872dr$8u9@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

John,

(Before replying, I notice that in the following Outlook Express insists  on
turning //. into file://." . Can anyone tell me how to prevent this?)

The behaviour in Version 4.1 is caused by parsing from the right until a
complete expression is found.

{a,c}//.{a->b}
//.  {c->d}

        {b,c}

Syntax::tsntxi: "//.  {c->d}" is incomplete; more input is needed.

//.  {c->d}

If we want to tell Mathematica that there is more, a simple way is to use
parentheses

({a, c} //. {a -> b}
//. {c -> d})

        {b,d}

This explains why your examination with  Full Form did not show up the
problem: the expression did not end until the last ].

FullForm[Hold[
    {a,c}//.{a->b}
      //.  {c->d}
    ]]

That pasting in from inside the above input works as one expreession seems
to be because of the already constructed cell expression:

Here is the cell expression for the paste in from FullForm[Hold[...] ]

Cell[BoxData[
    RowBox[{
      RowBox[{
        RowBox[{"{",
          RowBox[{"a", ",", "c"}], "}"}], "file://.",
        RowBox[{"{",
          RowBox[{"a", "\[Rule]", "b"}], "}"}]}], "\n", "file://.",

      RowBox[{"{",
        RowBox[{"c", "\[Rule]", "d"}], "}"}]}]], "Input",
  CellLabel->"In[20]:="]

We see that BoxData contains one outer RowBox.
    But for the oringinal,the cell expression has BoxData with a list of two
RowBoxes with "\n" between them.

Cell[BoxData[{
    RowBox[{
      RowBox[{"{",
        RowBox[{"a", ",", "c"}], "}"}], "file://.",
      RowBox[{"{",
        RowBox[{"a", "\[Rule]", "b"}], "}"}]}], "\n",
    RowBox[{"//.",
      RowBox[{"{",
        RowBox[{"c", "\[Rule]", "d"}], "}"}]}]}], "Input",
  CellLabel->"In[19]:="]


Incidentally this effect of pasting in from FullForm[Hold[..]] does not work
when we set
    menu > Cell > Default Input Format Type > InputForm
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"John A. Gunnels" <gunnels at cs.utexas.edu> wrote in message
news:9872dr$8u9 at smc.vnet.net...
> I have run into a rather odd "problem" (easily worked around, but ...)
> in my recent upgrade to Version 4.1.
>
> Under version 4.0, I could type and evaluate something
> like the following:
> x //. {a -> b}
>   //. {c -> d}
> [where I hit the return between "b}" and the second "file://."
>
> Now, under 4.1, this yields a syntax error:
> Syntax::tsntxi:
> "//. {c->d}" is incomplete; more input is needed
>
> while
> x //. {a -> b} //. {c -> d}
> works as expected (well, it's a simplified example
> which does nothing, but ... no syntax error and the
> analog in my application works).
>
> So I tried FullForm[Hold[<expression>]] with and without
> the line return (thinking that, perhaps, some odd character
> was inserted or something), only to see that the two were
> identical.  Further, copying and pasting from inside the
> evaluated FullForm[Hold[]], WITH a carriage return, gives
> me a cell that looks like the one that gives me a syntax
> error (above), yet no error is reported upon evaluation.
> FURTHER, if I copy and paste the "]" (the right brace
> corresponding to the "Hold["), then erase it (otherwise, of
> course, it's not syntactically correct), evaluating the cell
> gives me the same syntax error is above.
>
> I realize that this is fairly trivial, but I would like to
> know if anyone else has run into this.  It _seems_ like a
> _small_ bug to me, but ...
>
> Thanks,
> John A. Gunnels
> gunnels at cs.utexas.edu
>




  • Prev by Date: Re: Re: Re: controlling the size of tick marks
  • Next by Date: Re: Fibonacci
  • Previous by thread: Re: V4.1 Carriage Returns w/ ReplaceRepeated in Windows?
  • Next by thread: Re: exchanging 2 elements in a list (problem with Block)