MathGroup Archive 2006

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

Search the Archive

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


xiaochu wrote:
> Hi, All,
> 
> Another system's functions can have multiple returns, does
> Mathematica support this?

Sure. Multiple values are returned within a list. For example

In[1]:=
Solve[x^2 - 4 == 0, x]

Out[1]=
{{x -> -2}, {x -> 2}}

In[2]:=
NestList[#1^2 & , 2, 3]

Out[2]=
{2, 4, 16, 256}

In[3]:=
PrimeQ[Range[10]]

Out[3]=
{False, True, True, False, True, False, True, False,
   False, False}

Best regards,
Jean-Marc


  • Prev by Date: Automating PolarPlot with Polar Gridlines
  • Next by Date: Re: Applying rules to SparseArray
  • Previous by thread: Re: Beginner--How to simulate multiple returns for a function?
  • Next by thread: Re: Beginner--How to simulate multiple returns for a function?