RE: Re: A riddle: Functions that return unevaluated when they cannot

• To: mathgroup at smc.vnet.net
• Subject: [mg82777] RE: [mg82716] Re: A riddle: Functions that return unevaluated when they cannot
• From: "Ingolf Dahl" <ingolf.dahl at telia.com>
• Date: Tue, 30 Oct 2007 05:50:21 -0500 (EST)
• References: <ff9sin\$5vc\$1@smc.vnet.net> <ffckoe\$sop\$1@smc.vnet.net> <ffed3p\$bg7\$1@smc.vnet.net> <ffhqss\$4mr\$1@smc.vnet.net> <fg4d62\$681\$1@smc.vnet.net> <200710300816.DAA12863@smc.vnet.net>

```But it is documented in the doc page for Condition. Look beneath "Scope"!

"Share a variable between a condition and function body:

In[1]:= f[x_] := Module[{u}, u^2 /; ((u = x - 1) > 0)]

In[2]:= f[0]

Out[2]= f[0]

In[3]:= f[6]

Out[3]= 25"

I must confess I do not really understand the use of the concept "Scope"
here.

Best regards

Ingolf Dahl

> -----Original Message-----
> From: Albert [mailto:awnl at arcor.net]
> Sent: den 30 oktober 2007 09:16
> To: mathgroup at smc.vnet.net
> Subject: [mg82716] Re: A riddle: Functions that return
> unevaluated when they cannot
>
> Szabolcs Horv=C3=A1t wrote:
> > Albert wrote:
> >> Hi,
> >>
> >> Is this what you are looking for?
> >
> > Yes, it it.  Thank you!  My newsreader has misplaced your
> message, so
> > I=
>
> > did not notice it until now.
> >
> > A function like
> > g[x_] := Module[{res}, Pause[3]; res = x + 2; res /; res < 10]
> > reproduces the timing behaviour of Integrate[] et al. :-)
> I was not
> > familiar with this use of /; (it is described in the doc page of
> > Module=
> ,
> > not in the doc page of Condition)
>
> ah, now I know that it is at least documented somewhere, also
> to my understanding it is not clear from the docpage (and
> also not from the examples or the old documentation in
> version 5) what exactly it does.
> Strange. But well, it works and seems to stay there... And for
> completeness: With and Block have the same part in their docpages.
>
> albert
>
>
>

```

• Prev by Date: Re: Re: Converting notebooks to use Mathematica Player