MathGroup Archive 2005

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

Search the Archive

Re: Return[] in pure function

  • To: mathgroup at
  • Subject: [mg58881] Re: Return[] in pure function
  • From: OT <montoz at>
  • Date: Fri, 22 Jul 2005 01:58:31 -0400 (EDT)
  • References: <dbou77$sqm$>
  • Sender: owner-wri-mathgroup at

dh ha scritto:
> Hi,
> I seems to me that there is a bug in the implementation of pure 
> functions. If somebody can explain the following behaviour it would be 
> interessting. If not, maybe Wolfram can contribute something.
> Consider
> f[x_]:= If[x==0,Return[Error],x];
> f /@ {1,0}
> gives {1,Error} what is fine.
> Now replace the function by a pure function:
> If[#==0,Return[Error],#]& /@ {1,0}
> this gives {1,Return["Error"]}. The Return statement has not been evaluated.
> sincerely, Daniel

Return[expr] exits control structures within the definition of a 
function, and gives the value expr for the whole function.

I think Return *must* be called inside a not-pure function: if you write 
Return[Error] you get "Return[Error]" as output...

  • Prev by Date: Re: New to Mathematica- How to write functions????????
  • Next by Date: Re: Returnin pure function
  • Previous by thread: Return[] in pure function
  • Next by thread: Re: Return[] in pure function