Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: precedence for ReplaceAll?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110583] Re: precedence for ReplaceAll?
  • From: AES <siegman at stanford.edu>
  • Date: Sat, 26 Jun 2010 03:12:23 -0400 (EDT)
  • Organization: Stanford University
  • References: <hvv4ti$fc$1@smc.vnet.net> <i023lj$r3c$1@smc.vnet.net>

In article <i023lj$r3c$1 at smc.vnet.net>,
 Albert Retey <awnl at gmx-topmail.de> wrote:

> 
> No, what actually happens is that a and b are evaluated to A*c and B*c
> respectively, even before the ReplaceAll sees them. Then the ReplaceAll
> sees
> 
> A*c+B*c /. {A*c -> x, B*c -> y}
> A*B*c^2 /. {A*c -> x, B*c -> y}
> 
> where it will find matches in the first case but not in the second and
> so does nothing. 

I'm guessing that in the initial evaluation stage(s) referred to above, 
any and all "superfluous" parens are also stripped out, so that even if 
the OP had started with

   a := (A c)
   b := (B c)

(and maybe inserted protecive parens at various places in subsequent 
line, the results would have been exactly the same . . . ?

Would there be a place in Mathematica for a "FindAndReplaceText[-]" 
command that would do the equivalent of a word processor's "Find and 
Replace" operation ***on the literal text string that was typed into a 
Mathematica cell*** (or that appeared on screen in an Output cell), 
without doing any evaluation at all, before or afterwards?

Thinking that this is what ReplaceAll does (or should do) is obviously 
the source of a lot of misinterpretation and trouble for Mathematica
users.  But maybe defining such a command, and determining what it should and 
shouldn't do would be too difficult or too complicated to be 
realistically possible.


  • Prev by Date: Re: Image processing Questions
  • Next by Date: Creating sub-list based on a given criterion
  • Previous by thread: Re: precedence for ReplaceAll?
  • Next by thread: Re: precedence for ReplaceAll?