MathGroup Archive 2012

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

Search the Archive

Re: replace one rule in a list of rules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125553] Re: replace one rule in a list of rules
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sun, 18 Mar 2012 02:46:42 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201203170751.CAA05105@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Not sure what you mean by "repeatedly replace one of [the rules]". After 
all, if you have a list of rules with repeats, e.g.,

     myrules = {a -> b, c -> d, e -> f, c -> d};

then you could get rid of the repeats by using, say, Union:

     simplerules = Union@myrules
{a->b,c->d,e->f}

So your problem really seems to be to replace _one_ of the rules. And 
then replace that one rule just as you'd replace anything, e.g.:

   simplerules/.(c->d)->(c->wow)
{a->b,c->wow,e->f}

Or is your problem something else?

On 3/17/12 3:51 AM, Kathryn Isaac wrote:
> I have a list of simple rules. I want to repeatedly replace one of
> them.  Is the best way to simply prepend the new rules, or is there a
> "prettier" approach?
>
> Thanks,
> Alan Isaac
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305



  • Prev by Date: Re: new functional operator
  • Next by Date: Re: Creating List
  • Previous by thread: replace one rule in a list of rules
  • Next by thread: Re: replace one rule in a list of rules