       Re: Argument types

• To: mathgroup at smc.vnet.net
• Subject: [mg5368] Re: [mg5345] Argument types
• From: Allan Hayes <hay at haystack>
• Date: Thu, 5 Dec 1996 14:50:14 -0500
• Sender: owner-wri-mathgroup at wolfram.com

```From: Olivier Georg <olivier.georg at studi.epfl.ch>
To: mathgroup at smc.vnet.net
Subject: [mg5345] Argument types

> I recently discovered that you could specify the type of the
> arguments of a function being defined.  For example, f[x_Integer]
> if you want x to be an integer.  There's also List, Real, Complex
> and Symbol.  But there's also ?MatrixQ which is not in the
> Mathematica book, to specify a matrix.  Are there other types?

Olivier,

_h is matched by anything with head h; this can be explicit for
example h[], h,h[1,2,3].
Unfortunately, you can't see 3 in the form Integer, but you can

Out= Integer

The following tests always give True or False

AtomQ        DigitQ            EvenQ         FreeQ
IntegerQ     IntervalMemberQ   LetterQ       ListQ
LowerCaseQ   MachineNumberQ    MatchQ        MatrixQ
MemberQ      NameQ             NumberQ       OddQ
OptionQ      OrderedQ          PolynomialQ   PrimeQ
SameQ        StringMatchQ      StringQ       SyntaxQ
TrueQ        UnsameQ           UpperCaseQ    ValueQ

Then there are tests that remain unevaluated when the question
cannot be decided on the information available:

Equal         Unequal        Less       Greater
LessEqual     GreaterEqual   Positive   Negative
NonNegative

For example

In:= Positive[a]
Out= Positive[a]

However, you can always arrange that the output is always True or
False by using TrueQ:

In:= TrueQ[Positive[a]]
Out= False

You can sometimes combine these:
For example test if the entries in a matrix are all numbers:

In:= MatrixQ[{{1},{2}},NumberQ]
Out= True

In:= MatrixQ[{{1},{a}},NumberQ]
Out = False

Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk

```

• Prev by Date: Mathematica etc.
• Next by Date: Re: 3D data plot
• Previous by thread: Re: Re: Mathematica etc.
• Next by thread: Re: Argument types