Defining a predicate
- To: mathgroup at yoda.physics.unc.edu
- Subject: Defining a predicate
- From: Michael Carter <ECON076 at cantva.canterbury.ac.nz>
- Date: Tue, 21 Jun 1994 11:02:25 +1200
I want to define a predicate (TableauQ) to recognise a system (list) of
equations, so that I set $PrePrint to apply TableForm to such a
system. The following works:
TableauQ[_] := False
TableauQ[{_Equal..}] := True
$PrePrint = If[TableauQ[#], TableForm[#],#]&;
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 Mma 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?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Michael Carter m.carter at econ.canterbury.ac.nz
Department of Economics voice: + 64 3 364 2524
University of Canterbury fax: + 64 3 364 2635
Private Bag 4800
Christchurch
NEW ZEALAND