Re: returning variable number of arguments from a Module[ ]

*To*: mathgroup at smc.vnet.net*Subject*: [mg71593] Re: [mg71477] returning variable number of arguments from a Module[ ]*From*: "厉正吉" <zhengji.li at gmail.com>*Date*: Fri, 24 Nov 2006 01:17:13 -0500 (EST)*References*: <200611201117.GAA07275@smc.vnet.net>

Hello, Please take a look at my codes. It seems to be exactly what you need. In[17]:= Unprotect[Set]; (* Let's add some features to "=" *) In[24]:= Set[{W_, Y_}, f[x_, y_]] := {W, Y} = Module[{t, s}, t = x + y; s = t*y; {s, t}]; Set[w_, f[x_, y_]] := w = Module[{t, s}, t = x + y; s = t*y; s]; In[35]:= w = f[x, y]; {W, Y} = f[x, y]; w W Y Out[37]= y (x + y) Out[38]= y (x + y) Out[39]= x + y Since here we add some definitions to "Set" which is commonly used, the kernel may be slowed down signaficantly. So it is not recommended. On 11/20/06, bd satish <bdsatish at gmail.com> wrote: > Hi , > > Is there any method to return a variable number of arguments from a > Module[ ] or Block[ ] depending upon the o/p list ? > > For example, consider a module > > f[x_,y_]:= Module[ {t,s} , t=x+y; s = t*y ] > > Also assume that , the variable 's' has higher priority than 't' . So when > a user types a single o/p variable i.e. > > W = f[x,y] then W should have the same value as 's' in the > module > > { W, Y } = f[x,y] then W points to 's' and 'X' points to 't' > > If I try to do the above ,I'm getting some warning messages.. > > Please help. > > > -- Li Zhengji ------------------------------------------------------------- If all you have is a hammer, everything is a nail. -------------------------------------------------------------

**References**:**returning variable number of arguments from a Module[ ]***From:*"bd satish" <bdsatish@gmail.com>