Re: ReplaceAll doesn't replace
- To: mathgroup at smc.vnet.net
- Subject: [mg32561] Re: [mg32550] ReplaceAll doesn't replace
- From: Ken Levasseur <Kenneth_Levasseur at uml.edu>
- Date: Sun, 27 Jan 2002 03:28:48 -0500 (EST)
- References: <200201260908.EAA14512@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Ken:
The reason nothing is happening to x in (#^2 & /@ x) is that you're using
Map, which will map the function #^2& over the arguments of x, of which there
are none. You probably want (#^2 & @ x); or if you really want to use Map:
Map[#1^2 & , x, {0}], where the {0} specifies that the function is applied to
level 0, not level 1.
Ken Levasseur
Math. Sci.
UMass Lowell
Ken Morgan wrote:
> 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
- References:
- ReplaceAll doesn't replace
- From: "Ken Morgan" <kmorga51@calvin.edu>
- ReplaceAll doesn't replace