MathGroup Archive 2006

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

Search the Archive

Re: Beginner--How to simulate multiple returns for a function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66454] Re: Beginner--How to simulate multiple returns for a function?
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 14 May 2006 02:57:27 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <Pine.GSO.4.44.0605100054500.17163-100000@smc> <e3v0tt$pav$1@smc.vnet.net> <e419hj$h6p$1@smc.vnet.net> <e43vfe$8s3$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Robert Dodier wrote:
> Jens-Peer Kuska wrote:
> 
>> what are multiple returns ?
> 
> Probably what the original poster wants is not just to return a list,
> but to return a list and assign its elements to multiple variables.
> E.g. Python understands the following
> 
>    (A, B, C) = (1, 2, 3)
> 
> to mean A = 1, B = 2, C = 3. Lisp has several similar constructs
> (MULTIPLE-VALUE-BIND and so on).
> 
> Of course it would help if people would just come right out and
> say what they want.
> 
> FWIW
> Robert Dodier
> 
Hi Robert,

We can do that in Mathematica too. Just replace parenthesis by curly 
braces as in

In[1]:=
Clear[a, b, c]
a + b + c
{a, b, c} = {1, 2, 3}
{c, b, a}
a + b + c
{a, b, c} == {1, 2, 3}

Out[2]=
a + b + c

Out[3]=
{1, 2, 3}

Out[4]=
{3, 2, 1}

Out[5]=
6

Out[6]=
True

Best regards,
Jean-Marc


  • Prev by Date: RE: Re: Beginner--How to simulate multiple returns for a function?
  • Next by Date: Re: Re: Re: Do Mathematica applications EVER get updated?
  • Previous by thread: RE: Re: Beginner--How to simulate multiple returns for a function?
  • Next by thread: Automating PolarPlot with Polar Gridlines