Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: ReplaceAll doesn't replace

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

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

{(#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.


  • 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