MathGroup Archive 2001

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

Search the Archive

Re: [?] apply a function to members of a list


Hi,

Notice that Sin[alist] returns desired.
That is because Sin is being Listable. Try ??Sin

Add attribute Listability to user-defined function.
SetAttribute[f,Listable]

Way 2:
{f[1], f[1.5], f[7], f[4], f[3], f[2001]}
is read as "f is being mapped down the list"
So try Map[f,alist] or f/@alist


Read Wolfram's introduction to Mathematica, where this and more are treated
nicely.


bye,
Borut


9donco <chindonco at iname.com> wrote in message
news:94gs7d$qvp at smc.vnet.net...
> hi all,
>
> I have a list of arbitrary numbers eg. alist={1, 1.5, 7, 4, 3, 2001}
> and a (user-define) function  f[]
>
> Is there a quick way/operation to apply f to indiviual
> elements in alist ? say, to produce:
>
> {f[1], f[1.5], f[7], f[4], f[3], f[2001]}
>
> Please help !
> thank you in advance
> 9DonCo
>
>
>




  • Prev by Date: Fw: Compiling a function using Module
  • Next by Date: RE: [?] apply a function to members of a list
  • Previous by thread: Re: [?] apply a function to members of a list
  • Next by thread: RE: [?] apply a function to members of a list