MathGroup Archive 1999

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

Search the Archive

Re: Q: extracting list of arguments of function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16493] Re: [mg16468] Q: extracting list of arguments of function
  • From: "Carl K.Woll" <carlw at fermi.phys.washington.edu>
  • Date: Tue, 16 Mar 1999 03:59:45 -0500
  • Organization: Department of Physics
  • References: <199903130722.CAA24544@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Jerzy,

You need to prevent the evaluation of your argument before your function
starts. To do this, gived foo the attribute HoldFirst. For example,

In[13]:=
SetAttributes[foo,{HoldFirst}]
foo[fun_]:=List@@Unevaluated[fun]

Then, for example,

In[15]:=
goo[x,y]=1;
foo[goo[x,y]]
Out[15]=
{x,y}

Carl Woll
Dept of Physics
U of Washington

Jerzy Niesytto wrote:

> Let's assume that we want to pass function goo as argument
> to another function foo and extract list of arguments
> of the function goo:
> foo[fun_] := Module[{argList}, argList = Table[fun[[i]],{i,1,2}] ]
> foo[goo[x,y]];
>
> This will result in list:
> {x,y}
>
> But if goo was defined before eg:
> goo[s_,t_] = s^2 + t^3;
>
> then we get:
> {x^2,y^3} .....
>
> Can anybody point me in a right direction here?
> Sorry for such an elementary question...
>
> JT





  • Prev by Date: FrontEndExecute returns Null
  • Next by Date: Re: Problem: Smallest sphere including all 3D points
  • Previous by thread: Re: Q: extracting list of arguments of function
  • Next by thread: Re: Q: extracting list of arguments of function