       RE: ReplaceAll (/.)

• To: mathgroup at smc.vnet.net
• Subject: [mg69213] RE: [mg69197] ReplaceAll (/.)
• From: "David Park" <djmp at earthlink.net>
• Date: Fri, 1 Sep 2006 18:41:27 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Bruce,

Try

(a b) /. x_Times -> List @@ x // Trace

If you want delayed evaluation of the rhs of the rule you have to use
RuleDelayed.

David Park

From: Bruce Colletti [mailto:vze269bv at verizon.net]
To: mathgroup at smc.vnet.net

Re Mathematica 5.2.0.0.

Why doesn't:

(a b) /. x_Times -> List @@ x

return {a,b}?  My (flawed) reasoning is that a b has form Times[a,b], and so
x matches to Times[a,b].  List@@x replaces Times with List to yield
List[a,b], or {a,b}...or so it would seem.

The explanation is somehow linked to the fact that:

(a b) /. x_Times :> List @@ x

returns {a,b}, but I don't see why this works but not the above.

Although List@@(a,b) returns {a,b}, I want to use the above ReplaceAll
function (this example here is taken from a larger problem).

Thankx.

Bruce

```

• Prev by Date: Please help: How to use Mathematica to get Parametric solution for a transcendental equation?
• Next by Date: Re: ReplaceAll (/.)
• Previous by thread: Re: Re: ReplaceAll (/.)
• Next by thread: Re: ReplaceAll (/.)