MathGroup Archive 1993

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Applying a set of rules to a List

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

Tony Varghese <avarg at> 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[89]:= oldEqns = {a,b,c,d}

  Out[89]= {a, b, c, d}

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

  Out[90]= {a -> A, c -> C}

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

  In[92]:= newEqns = Map[ applyRules, oldEqns ]

  Out[92]= {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)
of your equations.

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