MathGroup Archive 1996

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

Search the Archive

Re: Argument types

Olivier Georg <olivier.georg at> wrote:

>I recently disovered that you could specify the type of the arguments
>of a function being defined.  For exemple, 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?

This form of checking applies the function MatrixQ to expression x and
allows the argument to pass only if the result is True.  As a result
you can write your own functions to preform the check.

For example:

TriadQ[x_List] := (Length[x]===3);
F[x_?TriadQ] := ...

To answer your original question NumberQ, IntegerQ, EvenQ, OddQ,
PrimeQ, PolynomialQ, VectorQ and MatrixQ are the built in functions I


  • Prev by Date: Re: A Bug in Parametric Plot ?
  • Next by Date: Re: Re: Speed of dot product in Mathematica
  • Previous by thread: Re: Argument types
  • Next by thread: Re: Re: Argument types