Re: Re: ReplaceAll (/.)

*To*: mathgroup at smc.vnet.net*Subject*: [mg69233] Re: [mg69203] Re: [mg69197] ReplaceAll (/.)*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Sun, 3 Sep 2006 01:39:35 -0400 (EDT)*References*: <200609011041.GAA25660@smc.vnet.net> <200609012241.SAA25633@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

It would be nice to know why list applied to an atomic object isn't an error. Anyone? On 9/1/06, Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > > On 1 Sep 2006, at 11:41, Bruce Colletti wrote: > > > 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 > > > > > You need to use RuleDelayed (:>) rather than Rule (->) because, if > you use just Rule, List@@x is first evaluated and gives: > > > > List@@x > > > x > > So all you are actually doing is > > (a b) /. x_Times -> x > > Andrzej Kozlowski > > -- http://chris.chiasson.name/

**References**:**ReplaceAll (/.)***From:*Bruce Colletti <vze269bv@verizon.net>

**Re: ReplaceAll (/.)***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>