MathGroup Archive 2007

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

Search the Archive

Re: pattern

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84379] Re: pattern
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Thu, 20 Dec 2007 00:17:48 -0500 (EST)
  • References: <3eb7b73d-e7dd-488e-abdc-0d0d1473258d@x69g2000hsx.googlegroups.com> <fkanuj$dlh$1@smc.vnet.net>

This is an example:

f[x : {{_?NumericQ, _?NumericQ}, {_?NumericQ, _?NumericQ}}] := x

The pattern object {{_?NumericQ, _?NumericQ}, {_?NumericQ, _?NumericQ}} 
matches a numerical 2x2 matrix, and the x: preceding it is the name that I 
have assigned to this pattern object for use inside the function definition.

If you want to match other types of matrix element then change the tests as 
necessary.

Stephen Luttrell
West Malvern, UK

<orelang at gmail.com> wrote in message news:fkanuj$dlh$1 at smc.vnet.net...
>I want to define a function that accepts only one argument - a 2x2
> matrix and not any more.
>
> Is it possible?
>
> orelang 



  • Prev by Date: Re: FileNameSetter button return state
  • Next by Date: Re: Trouble with double factorial and an infinite product
  • Previous by thread: Re: Re: pattern
  • Next by thread: Re: pattern