- To: mathgroup at smc.vnet.net
- Subject: [mg128268] Sum pattern
- From: "Dave Snead" <dsnead6 at charter.net>
- Date: Wed, 3 Oct 2012 03:07:29 -0400 (EDT)
- Delivered-to: firstname.lastname@example.org
- Delivered-to: email@example.com
- Delivered-to: firstname.lastname@example.org
- Delivered-to: email@example.com
- References: <20120930000917.61B1A6865@smc.vnet.net>
I'm trying to put together a rule whose left hand side is a sum of arbitrary
length whose elements all have the same head f.
In:= x = f[a1, s] + f[a2, s] + f[a3, s]
Out= f[a1, s] + f[a2, s] + f[a3, s]
In:= y = f[First /@ x, s]
Out= f[a1 + a2 + a3, s]
which is what I want.
However when I turn this into a rule
In:= z = x /. (p : Plus[__f]) -> f[First /@ p, s]
Out= f[f[a1, s], s] + f[f[a2, s], s] + f[f[a3, s], s]
Why isn't z equal to y?
How can I make this rule work?
Thanks in advance,
Prev by Date:
issues with expression manipulation functions
Next by Date:
Re: Reduce command Mathematica
Previous by thread:
Re: issues with expression manipulation functions
Next by thread:
Re: Sum pattern