- To: mathgroup at smc.vnet.net
- Subject: [mg23826] Pattern Matching
- From: "Johannes Ludsteck" <ludsteck at zew.de>
- Date: Sat, 10 Jun 2000 03:00:46 -0400 (EDT)
- Organization: Zentr. f. Europ. Wirtschaftsforsch
- Sender: owner-wri-mathgroup at wolfram.com
Dear Group Members,
I would like to "find" and replace expressions with the simple
structure x b+x b2]+...+x[n] b[n]
I tried to use the following replacement rule
In:= x b + x b /. Plus[Times[x[_], b[_]] ..] -> z
Out= b x + b x + b x
Which didn't work (Out should be z).
The following FullForm seems to give exactly the structure I used
in my replacement rule.
FullForm[x b + x b + x b]
Plus[Times[b, x], Times[b, x], Times[b, x]]
Even if this worked, my pattern wouldn't account for equal indices,
i.e. it would match x b+x b, even if it shouldn't.
Centre for European Economic Research (ZEW)
Department of Labour Economics,
Human Resources and Social Policy
Email: ludsteck at zew.de
Prev by Date:
Re: Levenberg-Marquardt ?
Next by Date:
First Order Differential Equation
Previous by thread:
Re: PLEASE HELP!! Need to change symbols in LinearLogListPlot
Next by thread:
Re: Pattern Matching