RE: Applying my function to elements of a vector

*To*: mathgroup at smc.vnet.net*Subject*: [mg49494] RE: [mg49464] Applying my function to elements of a vector*From*: "Ellis, George" <George.Ellis at Cognos.COM>*Date*: Thu, 22 Jul 2004 02:45:03 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Something like this? f[x_] := x^2 vec = {1, 2, 3}; Map[f[#] &, vec] Regards, George -----Original Message----- From: Gregory Lypny [mailto:gregory.lypny at videotron.ca] To: mathgroup at smc.vnet.net Subject: [mg49494] [mg49464] Applying my function to elements of a vector Hello everyone, Say I've created a function, f[x_], which accepts a single scalar as its argument. I now want to apply that function to each element of a vector, v, of length n, as in newVector = f[v], but I get an error because my function f does not thread over the elements of the vector as do built-in Mathematica functions such as Log[]. How can I get my function to apply to each element of my vector? Regards, Greg This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you.