Re: substitution within a substitution list
- To: mathgroup at smc.vnet.net
- Subject: [mg88604] Re: substitution within a substitution list
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 9 May 2008 07:16:33 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fvudmu$ebg$1@smc.vnet.net>
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}
You could use a rule to change the rules:
subs /. (b -> x_) -> b -> 20
For instance,
In[1]:= subs = {a -> 1, b -> 2, c -> 2}
Out[1]= {a -> 1, b -> 2, c -> 2}
In[2]:= subs = subs /. (b -> x_) -> b -> 20
Out[2]= {a -> 1, b -> 20, c -> 2}
Regards,
-- Jean-Marc