MathGroup Archive 2002

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

Search the Archive

Re: ReplaceAll doesn't replace

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32571] Re: ReplaceAll doesn't replace
  • From: atelesforos at hotmail.com (Orestis Vantzos)
  • Date: Sun, 27 Jan 2002 03:29:02 -0500 (EST)
  • References: <a2tsuk$ea9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

This is a Trace[..] of your second expression:
In[7]:=
   2
(#1  & ) /@ x /. x -> {a, b, c}

Out[7]=
    2
{(#1  & ) /@ x, x}
{x -> {a, b, c}, x -> {a, b, c}}
x /. x -> {a, b, c}
{a, b, c}

As you can see, ReplaceAll never gets to see the square Function at
all. The reason for this is that f/@a returns a no matter what f
is...the reason for this is that the operator /@ applies f to the
first level of a, which just isn't there!
#^2& /@ {x} /. x->{a,b,c} will do the job just fine though.

Orestis


  • Prev by Date: RE: NestWhile
  • Next by Date: Re: Headless set of elements?
  • Previous by thread: Re: ReplaceAll doesn't replace
  • Next by thread: Re: ReplaceAll doesn't replace