Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg32569] Re: [mg32550] ReplaceAll doesn't replace
  • From: BobHanlon at aol.com
  • Date: Sun, 27 Jan 2002 03:28:59 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 1/26/02 4:37:21 AM, kmorga51 at calvin.edu writes:

>I understand how the following will replace x with the list
>
>#^2 & /@ (x /. x -> {a, b, c})
>
>to generate
>
>{a^2, b^2, c^2}
>
>But, why isn't x replaced at the beginning of the evaluation in the
>following
>
>(#^2 & /@ x) /. x -> {a, b, c}
>
>since it generates
>
>{a, b, c}
>
>What I really want to know is: What is it about the Function function that
>doesn't allow ReplaceAll to "replace all" at the beginning of an evaluation?
>

Because

(#^2 & /@ x)

x

There was no list so there was no mapping.  To have the mapping occur, you 
would need to use

(#^2 & /@ {x}) /. x -> {a, b, c}

{{a^2, b^2, c^2}}


Bob Hanlon
Chantilly, VA  USA


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