Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg57215] Re: how to map function with over 1 arguments to list
  • From: Gareth Russell <gjr2008 at columbia.edu>
  • Date: Sat, 21 May 2005 02:39:28 -0400 (EDT)
  • Organization: Columbia University
  • References: <d6ka03$168$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 2005-05-20 05:17:55 -0400, "xun" <xiaoxun at gmail.com> said:

> 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.

Because in the map function you are sending f[] a two-element list when 
it is expecting two separate arguments. Redefine f[] to expect a list...

In[463]:=
f[{x_,y_}]:=x+y

In[464]:=
f/@{{1,1},{2,2}}

Out[464]=
{2,4}


  • Prev by Date: Re: how to map function with over 1 arguments to list
  • Next by Date: Re: how to map function with over 1 arguments to list
  • 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