If Return[x] is generated as a value in Do or Scan then x is immediately
returned;
If Return[x] is generated as an entry in CompoundExpression or as a value
of the body of a While or For loop then Return[x] (not x) is immediately
returned;
If Return[x] is generated as the value of a user-defined function then the
function returns x (not Return[x])
Otherwise Return[x] behaves as a ordinary expression.
EXAMPLES
Do[Return[2],{4}]
Scan[If[#>1,Return[#]]&, {1,2,3}]
2
2
1;Return[2];3
While[True, Return[2]]
For[1,True,2, Return[2]]
Return[2]
Return[2]
Return[2]
f[x_]:= Return[x]
f[2]
2
{Return[2]}
{Return[R[2]]}
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
h...@haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565