Re: Argument types
- To: mathgroup at smc.vnet.net
- Subject: [mg5402] Re: Argument types
- From: dreece at atl.mindspring.com (Daryl Reece)
- Date: Thu, 5 Dec 1996 14:50:35 -0500
- Organization: MindSpring Enterprises, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
Olivier Georg <olivier.georg at studi.epfl.ch> 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 know. -Daryl