Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1994
*January
*February
*March
*April
*May
*June
*July
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1994

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

Search the Archive

Re: Defining a predicate

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Defining a predicate
  • From: Roman Maeder <maeder at inf.ethz.ch>
  • Date: Mon, 27 Jun 1994 10:38:18 +0200

> The following works:
> 
> 	TableauQ[_] := False
> 	TableauQ[{_Equal..}] := True
> 
> However, the logic of providing a blanket False (TableauQ[_] := 
> False), which is then overridden when appropriate pattern matches, 
> bothers me. Is the explicit False necessary?
> 
> On p. 227 of the good book, Wolfram writes:
> 
> 	An important feature of Mathematica property-testing functions whose 
> names end in Q is that they always return False if they cannot 
> determine whether the expression has the given property. 
> 
>  That behaviour also seems appropriate in my example. Is it possible
> to make user defined predicates exhibit the same behaviour?

Using names that end in Q is a convention; the desired behaviour is not
automatic. Your use of the catchall rule is good programming style.
You should, however, put that rule last. If there were any other rules
with side condition (in the form TableauQ[..] /; cond := ...), the automatic
rule ordering would not work.

Roman Maeder






  • Prev by Date: Help needed in Mathematica
  • Next by Date: unwarranted assumption?
  • Previous by thread: Defining a predicate
  • Next by thread: Re: Defining a predicate