MathGroup Archive 2006

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71501] Re: returning variable number of arguments from a Module[ ]
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Mon, 20 Nov 2006 18:12:04 -0500 (EST)
  • Organization: Customer of PlusNet plc (http://www.plus.net)
  • References: <ejs38c$94b$1@smc.vnet.net>

bd satish 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.
> 
> 
Hello,

I found it tough to understand this question - so it is possible that I 
have misunderstood you, but the simple answer is that f[x,y] will be 
evaluated before the assignment of which it is the RHS. Also, in your 
module, there is no point in including the variable s - you might as 
well put the expression t*y as the final value.

If f always returns a list of three objects (say) you could always trim 
that subsequently as required as part of the assignment:

{W,Y}=Take[f[x,y],2];

To be honest, I suspect that there is a better way of solving whatever 
it is that you are trying to do - why not tell us more?

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Send graphics to file AND/OR to notebook with one DisplayFunction
  • Next by Date: ComplexityFunction affects set of transformations tried by Simplify
  • Previous by thread: Re: returning variable number of arguments from a Module[ ]
  • Next by thread: Re: returning variable number of arguments from a Module[ ]