Re: ReplaceAll and rules from a list v7.0

• To: mathgroup at smc.vnet.net
• Subject: [mg104244] Re: ReplaceAll and rules from a list v7.0
• From: "Nasser M. Abbasi" <nma at 12000.org>
• Date: Sun, 25 Oct 2009 01:04:54 -0400 (EDT)
• References: <hbu7qi\$7hn\$1@smc.vnet.net>

```"kristoph" <kristophs.post at web.de> wrote in message
news:hbu7qi\$7hn\$1 at smc.vnet.net...
> 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.
>
> Kristoph
>

This is one of the problems there there is probably 10 ways to do in
Mathematica.

Here is one way, but I am sure there is a short way to do this. Map a
replacement rule to the list.

x = a + b;
list = {{1, 1}, {2, 2}, {3, 3}};

(x /. {a -> #1[[1]], b -> #1[[2]]} & ) /@ list

{2, 4, 6}

--Nasser

```

• Prev by Date: Re: How to format Superscript and Subscript for a symbol to the same
• 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