Re: substitution within a substitution list
- To: mathgroup at smc.vnet.net
- Subject: [mg88592] Re: substitution within a substitution list
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 9 May 2008 03:25:24 -0400 (EDT)
On 5/8/08 at 4:13 AM, bipin.caz at googlemail.com (Bipin) wrote:
>I'm trying to find a way of changing the substitution values within
>a substitution list.
>For example, if I have the following substitution list:-
>subs = {a->1, b->2, c->2}
>I want to programmatically replace the value associated with 'b'
>from 2 to 20, ie ending up with
>subs = {a->1, b->20, c->2}
>Does anyone know of a mathematica function for doing this?
Sure. Use a replacement rule with HoldPattern. For example,
In[4]:= subs /. HoldPattern[a_ -> _] -> a -> 20
Out[4]= {a->20,b->20,c->20}