MathGroup Archive 2009

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

Search the Archive

Re: evaluate f[{x,y,z}] when f[x,y,z] defined

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103392] Re: [mg103383] evaluate f[{x,y,z}] when f[x,y,z] defined
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Sun, 20 Sep 2009 06:19:40 -0400 (EDT)
  • References: <200909190926.FAA22303@smc.vnet.net>

Hi,

just replace the List head of {1,2,3} by Sequence head.

f[x_, y_, z_] := Sqrt[x^2 + y^2 + z^2];
a = {1, 2, 3};
f[Sequence @@ a]


Cheers
Patrick

On Sat, 2009-09-19 at 05:26 -0400, Murray Eisenberg wrote:
> I ought to know how to do this (simply) but don't, or at least don't 
> recall how...
> 
> Often I have a function of several variables defined, for example:
> 
>    f[x_, y_, z_] := Sqrt[x^2 + y^2 + z^2]
> 
> And I have some list of numbers, e.g.:
> 
>    a = {4, 3, 2};
> 
> How can I evaluate the following...
> 
>    f[a]
> 
> ... without having to make a separate definition such as
> 
>    f[{x_, y_, z_}] := f[x, y,z]
> 
> ?
> 



  • Prev by Date: Modifying Default Stylesheet?
  • Next by Date: Re: defined
  • Previous by thread: evaluate f[{x,y,z}] when f[x,y,z] defined
  • Next by thread: Re: evaluate f[{x,y,z}] when f[x,y,z] defined