Re: Questions about functions.
- To: mathgroup@smc.vnet.net
- Subject: [mg11807] Re: Questions about functions.
- From: dreissNOSPAM@nospam.earthlink.net (David Reiss)
- Date: Tue, 31 Mar 1998 02:28:27 -0500
- Organization: EarthLink Network, Inc.
- References: <6esdkf$57j@smc.vnet.net> <6f1lvm$f9n@smc.vnet.net> <6fi7ca$4ri@smc.vnet.net>
In article <6fi7ca$4ri@smc.vnet.net>, El alchemista
<jaimeco@pecos.rc.arizona.edu> wrote:
> I will appreciate your input to these two questions.
>
> 1 - How can I convert the sequence of all arguments of a function into
> a list ? In vain I tried f[x__] := List @@ x
>
>
> 2 - How can I make functions which use their own names , for instance so
> that s[e,f] for some symbol s and all expressions e , f
> becomes (s+e)(s+f) ?
>
>
> Many thanks
>
> jaime Combariza
> jaimeco@arizona.edu
1 - How can I convert the sequence of all arguments of a function into
a list ? In vain I tried f[x__] := List @@ x
This does what you want:
In[14]:= Clear[f]
In[15]:=
Clear[f];
f[x__] := List@x
In[16]:= f[a,b,c,d]
Out[16]= {a,b,c,d}
Or equivalently,
In[17]:=
Clear[f];
f[x__] := {x}
In[18]:= f[a,b,c,d]
Out[18]= {a,b,c,d}
2 - How can I make functions which use their own names , for instance so
that s[e,f] for some symbol s and all expressions e , f
becomes (s+e)(s+f) ?
The following seems to work for the example that you give. Perhaps you
want something more involved?
In[19]:=
Clear[s];
s[e_,f_] :=(s+e)(s+f)
In[20]:= s[x,z]
Out[20]= (s+x) (s+z)
--
David Reiss
dreissNOSPAM@nospam.earthlink.net
http://home.earthlink.net/~dreiss
To send personal email, remove the words "nospam" and "NOSPAM" from the
email address