Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

RE: Applying my function to elements of a vector

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49488] RE: [mg49464] Applying my function to elements of a vector
  • From: "Owen, HL (Hywel)" <H.L.Owen at dl.ac.uk>
  • Date: Thu, 22 Jul 2004 02:44:52 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Thread[] or Map[] will usually do this. If you have trouble with this method
(depends on what's in the function), you can also use: f[#]&/@v which will
Map f over the first level in v.

Hywel

-----Original Message-----
From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
To: mathgroup at smc.vnet.net
Subject: [mg49488] [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


  • Prev by Date: RE: simple problem with Map?!?
  • Next by Date: RE: simple problem with Map?!?
  • Previous by thread: RE: Applying my function to elements of a vector
  • Next by thread: RE: Applying my function to elements of a vector