       Re: Get list of function variables?

• To: mathgroup at smc.vnet.net
• Subject: [mg83313] Re: [mg83258] Get list of function variables?
• From: DrMajorBob <drmajorbob at bigfoot.com>
• Date: Sat, 17 Nov 2007 05:24:07 -0500 (EST)
• References: <29455150.1195212238501.JavaMail.root@m35>
• Reply-to: drmajorbob at bigfoot.com

```Strictly speaking, f, g, and h (a) are not functions and (b) do not have
variables.

In this example:

f[x_,y_]:=a*x^2+b*y^2

f may act like a function, but it's actually a pattern-based rule -- and
it can have several, not just the one.

To find out what patterns f recognizes, you can look at

DownValues@f

{HoldPattern[f[x_, y_]] :> a x^2 + b y^2}

Bobby

On Fri, 16 Nov 2007 04:30:13 -0600, Jason Quinn
<jason.lee.quinn at gmail.com> wrote:

> This seems simple but how do I get the arguments to an arbitrary
> function? Ideally something like getVariables[f] that just accepts the
> function name as its argument.
>
> If I have f[x_,y_]:=a*x^2+b*y^2,  getVariables[f] should return {x,y}
> If I have g[n_,m_]:=a*n^2+b*m^2, getVariables[g] should return {n,m}
> If I have h[w_,x_,y_,z_]:=A*w*x*y*z+B, getVariables[h] should return
> {w,x,y,z}
>
> Thanks for any suggestions,
> Jason
>
>

--

DrMajorBob at bigfoot.com

```

• Prev by Date: Re: Default value for Dynamic InputField
• Next by Date: Re: Does ColorFunction-> have different meanings to Plot3D
• Previous by thread: Re: Get list of function variables?
• Next by thread: Get list of function variables?