       Re: Applying a set of rules to a List

• To: mathgroup at yoda.physics.unc.edu
• Subject: Re: Applying a set of rules to a List
• From: John Lee <lee at math.washington.edu>
• Date: Wed, 27 Jan 93 10:28:42 -0800

```Tony Varghese <avarg at s1.arc.umn.edu> writes:

> I would like to apply a set of rules to all the elements of a list and
> I've tried a number of things with no success.

> What I have is a set of equations in which certain variables are to be
> held at fixed values. The equations are stored as a list, say, oldEqns.
> The substitution rules are stored in a variable called fpRules.
> I need to get a new set of equations obtained by ReplaceAll'ing the
> old eqns with the fpRules.  Here is one attempt:

> 	applyRules[item_] := ReplaceAll[item, fpRules]

> 	newEqns = Map[ applyRules, oldEqns ]

> Unfortunately this did not work; I don't see any difference between
> oldEqns and newEqns even though I KNOW there are places where the rules
> can be applied.
> Anyone see the problem?

Your setup should work as it stands.  Here's a simple example:

In:= oldEqns = {a,b,c,d}

Out= {a, b, c, d}

In:= fpRules = {a->A, c->C}

Out= {a -> A, c -> C}

In:= applyRules[item_] := ReplaceAll[item, fpRules]

In:= newEqns = Map[ applyRules, oldEqns ]

Out= {A, b, C, d}

So my guess is that your rules aren't really doing what you want them to.
Perhaps the left-hand sides don't really match the internal form (FullForm)

Jack Lee
Dept. of Mathematics
University of Washington
Seattle, WA

```

• Prev by Date: SphericalHarmonicY Algorithm
• Next by Date: Graphics in 2.1
• Previous by thread: Applying a set of rules to a List
• Next by thread: multiple parametric plots