Re: Map
- To: mathgroup at smc.vnet.net
- Subject: [mg7464] Re: [mg7454] Map
- From: Richard Gass <gass at physics.uc.edu>
- Date: Thu, 5 Jun 1997 01:35:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Sean wrote >Does anyone know how to use Map if the mapping function has more than one >argument? > >ie: If I have a function f[x] and an array, then Map[f,array] applies f >to each >element of the array. What I want is a function f[x,y] and do something like >Map[f[#,3],array] so it will apply f[x,3] to every element of the array. >I currently >have two kludgey work arounds which is to make a new function g[x_]:=f[x,3] >then use Map[g,array] or to make a newarray={array,list of second arguments}, >then use MapThread.. I am looking for a better way > >Please reply to seanross at worldnet.att.net If my understanding of what you want is correct then you can do what you want by combining Map with a pure function. In[40]:= array={x,y,u,v,z} Out[40]= {x,y,u,v,z} In[41]:= Map[f[#,3]&,array] Out[41]= {f(x,3),f(y,3),f(u,3),f(v,3),f(z,3)} Richard Gass Department of Physics University of Cincinnati Cincinnati, OH 45221 phone- 513-556-0519 E-Mail gass at physunc.uc.edu