MathGroup Archive 2007

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

Search the Archive

Re: The uses of Condition (/;)

  • To: mathgroup at
  • Subject: [mg82970] Re: The uses of Condition (/;)
  • From: magma <maderri2 at>
  • Date: Mon, 5 Nov 2007 05:03:36 -0500 (EST)
  • References: <fgka9u$q02$>

On Nov 4, 12:26 pm, Thomas E Burton <tbur... at> wrote:
> Assuming that you mean (as in your examples for testing)
> A. pattern /; condition := definition
> I think A & B do yield the same results.
> Despite the fact that Condition has a higher Precedence than
> SetDelayed and RuleDelayed, Condition seems to apply itself the
> entire assignment or rule, not just the definition.  Perhaps the
> documentation emphasizes both A and B to bring out this somewhat
> unexpected behavior.

No, Condition does not apply itself to the entire assignment or rule.
the 2 definitions

j[x_] := Sqrt[x] /; x > 0
jj[x_] := (Sqrt[x] /; x > 0)

are equivalent. Condition (/; ) attaches itself to the nearest
expression on its left, in accordance to the precedence levels.
Indeed Condition is an exotic little beast.
Let's observe it in its natural habitat...
Evaluate the following:


As you see, Condition does not appear anywhere. Instead we see
RuleCondition and $Conditionhold, two"Top Secret" internal symbols.
Let's now observe Condition outside its natural habitat...
Evaluate the following:

Sqrt[x] /; x > 0

Here we finally see Condition in action, does not really do
very much. For some reason x gets replaced in the first argument, but
not in the second. Please note that Condition has HoldAll attribute.
Not yet satisfied we try...

Sqrt[x] /; 3 > 0
Sqrt[x] /; True
Sqrt[x] /; False

As we see, when we use Condition by itself, It reappears in the trace,
but there is no (simple?) way to make it evaluate to something
meaningful, even of the test is clearly passed or rejected.
It seems that Condition can only be used in the well-known ways, never
by itself
So my question is: what does Condition evaluates to, if test is True.
And if test is False?
Apparently there is no easy answer

  • Prev by Date: Re: Jagged Spine (MultinormalDistribution)
  • Next by Date: Re: Size of graphic
  • Previous by thread: Re: The uses of Condition (/;)
  • Next by thread: Re: Problem with supplying custom tick marks