Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Misprint in the Documentation?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116615] Re: Misprint in the Documentation?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 21 Feb 2011 19:30:19 -0500 (EST)

Use With as follows

f[x_] := With[{u = x - 1}, u^2 /; u > 0]

f[0]

f[0]

f[6]

25


Bob Hanlon

---- Alexey <lehin.p at gmail.com> wrote: 

=============
Hello,

On the Documentation page ref/Condition under "More information" field
we read: "lhs:=Module[{vars},rhs/;test] allows local variables to be
shared between test and rhs. You can use the same construction with
Block and With.  =BB". The hyperlink at the end of the citation directs
at the example for Module:

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

This method in this example also works with Block:

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

In[2]:= f[0]

Out[2]= f[0]

In[3]:= f[6]

Out[3]= 25

But it is seemed to be irrelevant to With:

In[1]:= f[x_]:=With[{u},u^2/;((u=x-1)>0)]
In[2]:= f[0]
During evaluation of In[2]:= With::lvws: Variable u$ in local variable
specification {u$} requires a value. >>
Out[2]= With[{u$},RuleCondition[$ConditionHold[$ConditionHold[u$^2]],(u
$=0-1)>0]]

Is it misprint or I loose something?


--

Bob Hanlon



  • Prev by Date: Re: Odd behaviour of solution of PDE
  • Next by Date: Re: FinancialData Function Not Working for Property "Members"
  • Previous by thread: Misprint in the Documentation?
  • Next by thread: Re: Misprint in the Documentation?