MathGroup Archive 2008

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

Search the Archive

Re: substitution within a substitution list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88590] Re: substitution within a substitution list
  • From: Albert Retey <awnl at arcor.net>
  • Date: Fri, 9 May 2008 03:25:01 -0400 (EDT)
  • References: <fvudmu$ebg$1@smc.vnet.net>

Bipin wrote:
> HI,
> 
> 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?

yes :-). ReplaceAll, or /. for short:

subs /. (b -> _) -> (b -> 20)

depending on your expression and where they come from this might be more
robust:

Replace[subs, (Rule | RuleDelayed)[b, _] -> (b -> 20), {1}]


hth,

albert


  • Prev by Date: RE: Formatting Problem with Summation Symbol
  • Next by Date: Re: list of dates
  • Previous by thread: Re: substitution within a substitution list
  • Next by thread: Re: substitution within a substitution list