Re: replace one rule in a list of rules
- To: mathgroup at smc.vnet.net
- Subject: [mg125556] Re: replace one rule in a list of rules
- From: Peter Pein <petsie at dordos.net>
- Date: Sun, 18 Mar 2012 02:47:44 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jk1fv4$515$1@smc.vnet.net>
Am 17.03.2012 08:54, schrieb Kathryn Isaac: > 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 > You can apply pattern matching to rules: In[12]:= rules = Thread[{a,b,c} -> {x,y,z}] Out[12]= {a -> x, b -> y, c -> z} In[13]:= newrules = rules /. HoldPattern[b -> _] :> b -> newy Out[13]= {a -> x, b -> newy, c -> z}