Re: About patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg9820] Re: [mg9713] About patterns
- From: BobHanlon at aol.com
- Date: Fri, 28 Nov 1997 05:35:35 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Here are two substitution rules depending on whether you want separate replacements. The parameter in the substitution definition enables you to expand the number of substitution rules. Bob Hanlon ___________________________________ substA[m_Integer] := (ToExpression["R" <> ToString[#]] * ToExpression["C" <> ToString[#]] x___:> A *x) & /@ Range[m] subAn[m_Integer] := (ToExpression["R" <> ToString[#]] * ToExpression["C" <> ToString[#]] x___:> ToExpression["A" <> ToString[#]] *x) & /@ Range[m] R1*R2*C1*C2 //. substA[2] \!\(A\^2\) R1*R2*R3*C1*C2*C3 //. substA[3] \!\(A\^3\) R1*R2*C1*C2 //. subAn[2] A1 A2 R1*R2*R3*C1*C2*C3 //. subAn[3] A1 A2 A3