MathGroup Archive 2009

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

Search the Archive

Re: ReplaceAll and rules from a list v7.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104280] Re: [mg104227] ReplaceAll and rules from a list v7.0
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Sun, 25 Oct 2009 01:11:38 -0400 (EDT)
  • References: <200910240640.CAA07557@smc.vnet.net>

Hi Kristoph,

I don't think assignments are really needed. The following seems to do what
you want while avoiding assignments to a and b in favor of local rules:

In[1] =
Clear[x,a,b];
x=a+b;

In[2] = x /. Thread[{a, b} -> Transpose[{{1, 1}, {2, 2}, {3, 3}}]]

Out[2] = {2, 4, 6}

Regards,
Leonid



On Fri, Oct 23, 2009 at 11:40 PM, kristoph <kristophs.post at web.de> wrote:

> Hi,
>
> Suppose I have the equation
>
> x=a+b
>
> and the list
>
> l={{1,1},{2,2},{3,3}}
>
> How can I quickly assign the list to the above equation, that is, I
> would like to get the following result
>
> {2,4,6}
>
> The first element of each sub-list should be assigned to a and the
> second to b.
>
> Thanks in advance.
> Kristoph
>
>



  • Prev by Date: Re: mathematica@linux, character encoding
  • Next by Date: RE: ReplaceAll and rules from a list v7.0
  • Previous by thread: Re: ReplaceAll and rules from a list v7.0
  • Next by thread: RE: ReplaceAll and rules from a list v7.0