[Date Index]
[Thread Index]
[Author Index]
Re: ReplaceAll (/.)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg69206] Re: ReplaceAll (/.)
*From*: email at email.com
*Date*: Fri, 1 Sep 2006 18:41:07 -0400 (EDT)
*References*: <ed9491$tu$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
(a b) /. x__Times -> List @@ x // Trace
gives
{{{List @@ x, x}, x__Times -> x, x__Times -> x},
a b /.\[InvisibleSpace]x__Times -> x, a b}
shows that List@@x is first evaluated before being applied when -> is
used (as should be). With RuleDelayed (:>) :
(a b) /. x__Times :> List @@ x // Trace
gives
{{x__Times :> List @@ x, x__Times :> List @@ x},
a b /.\[InvisibleSpace]x__Times :> List @@ x, List @@ (a b), {a, b}}
List@@x is evaluated after applying the rule.
GL
On Fri, 1 Sep 2006 11:07:13 +0000 (UTC), Bruce Colletti
<vze269bv at verizon.net> 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
Prev by Date:
**Re: Simplify UnitStep expressions**
Next by Date:
**Re: variable "K"? (Really strange behavior . . . )**
Previous by thread:
**Re: ReplaceAll (/.)**
Next by thread:
**Re: Re: ReplaceAll (/.)**
| |