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: [mg32572] Re: ReplaceAll doesn't replace
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sun, 27 Jan 2002 03:29:04 -0500 (EST)
  • References: <a2tsuk$ea9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Ken

The reason for the difference is bracketing.
Here are the main steps in the evaluations

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


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

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Ken Morgan" <kmorga51 at calvin.edu> wrote in message
news:a2tsuk$ea9$1 at smc.vnet.net...
> 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?
>
> Thanks,
> Ken Morgan
> kmorga51 at calvin.edu
>
>




  • Prev by Date: Re: Headless set of elements?
  • Next by Date: Q: Ticklabel inside the graph?
  • Previous by thread: RE: ReplaceAll doesn't replace
  • Next by thread: RE: ReplaceAll doesn't replace