MathGroup Archive 2002

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

Search the Archive

RE: Strange ReplaceAll behavior

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36792] RE: [mg36774] Strange ReplaceAll behavior
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Thu, 26 Sep 2002 04:56:42 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Sorry; disregard my earlier answer.  ru[c] isn't defined, so that
obviously wasn't the correct sequence of events.  Here's the right one:

f[c] == HoldPattern[(a+b)/.ru[a]]/.x->c == (a+b)/.ru[a] 
     == (a+b)/.a->x == x + b == b + x

The substitution of c for x occurs before the rule ru[a] is evaluated,
so there's no x in the expression to replace.  Instead, there's an 'a'
to replace with x.

If the other sequence had been correct, you have no rule for evaluating
ru[c], so it would have remained just that -- ru[c].  When the kernel
tried to apply it as a rule to (a+b), there would have been an error.
That didn't happen, so that wasn't the sequence of events.

Bobby Treat

-----Original Message-----
From: Lawrence A. Walker Jr. [mailto:lwalker701 at earthlink.net] 
To: mathgroup at smc.vnet.net
Subject: [mg36792] [mg36774] Strange ReplaceAll behavior

Hi,

For the life of me I am not sure why the following is not working in my 
v. 4.2:

ru[a]=a->x;
f[x_]:=(a+b) /. ru[a];

Why do I get
f[c] = b+x

and not
f[c] = b+c?

What gives?

Thanks,
Lawrence

-- 
Lawrence A. Walker Jr.
http://www.kingshonor.com





  • Prev by Date: Re: Strange ReplaceAll behavior
  • Next by Date: Re: C code for dual processor machine
  • Previous by thread: Re: Strange ReplaceAll behavior
  • Next by thread: RE: Strange ReplaceAll behavior