MathGroup Archive 2005

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

Search the Archive

Re: how to map function with over 1 arguments to list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57225] Re: [mg57205] how to map function with over 1 arguments to list
  • From: János <janos.lobb at yale.edu>
  • Date: Sat, 21 May 2005 02:39:49 -0400 (EDT)
  • References: <200505200844.EAA00690@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On May 20, 2005, at 4:44 AM, xun wrote:

> Hi, all,
>
> g[x_]:=x^2;
> g/@{1,2,3} results in{1,4,9}
>
> similarly, how to map f[x_,y_]:=x+y;
> to {1,1},{2,2}?
>
> it seems that f/@{{1,1},{2,2}} doesn't work.
>
> Thx.
> Xun
>
>
>
>
In[1]:=
f[x_, y_] := x + y;

In[4]:=
lst={{1,1},{2,2},{3,3}}

Out[4]=
{{1,1},{2,2},{3,3}}

In[9]:=
(f[#1[[1]], #1[[2]]] & ) /@
   lst
Out[9]=
{2, 4, 6}

This is what you need ?  Or did you mean:

In[21]:=
Total[lst]
Out[21]=
{6, 6}

János




  • Prev by Date: Re: how to map function with over 1 arguments to list
  • Next by Date: Re: GridLines issue
  • Previous by thread: Re: how to map function with over 1 arguments to list
  • Next by thread: Re: how to map function with over 1 arguments to list