Re: Q: extracting list of arguments of function
- To: mathgroup at smc.vnet.net
- Subject: [mg16509] Re: [mg16468] Q: extracting list of arguments of function
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Tue, 16 Mar 1999 03:59:54 -0500
- Sender: owner-wri-mathgroup at wolfram.com
There is no gain here from using Module here. The following simple code
will do what you want:
foo[fun_] := Table[Hold[fun][[1,i]],{i,1,2}];
SetAttributes[foo,HoldAll]
Now:
In[2]:=
goo[s_,t_] = s^2 + t^3 +Cos[s*t];
In[3]:=
foo[goo[x,y]]
Out[3]=
{x,y}
On Sat, Mar 13, 1999, Jerzy Niesytto <woland99 at earthlink.net> 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
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/