Re: how to build pattern for a square matrix of reals?
- To: mathgroup at smc.vnet.net
- Subject: [mg98392] Re: how to build pattern for a square matrix of reals?
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Thu, 9 Apr 2009 05:50:42 -0400 (EDT)
- References: <firstname.lastname@example.org>
You were almost there, but forgot the ampersand (&) which is necessary to complete the full pure function syntax. The whole part behind the ? should also be wrapped in an extra set of parentheses (this is also often necessary in cases where you use a pure function as an option): f[x_?((MatrixQ[#]) && Dimensions[#][] == Dimensions[#][] &)] Cheers -- Sjoerd On Apr 8, 11:03 am, sagra... at gmail.com wrote: > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for "square matrix" part: > f[x_?MatrixQ[#] && Dimensions[#][] == Dimensions[#][] > &] := ... > but it doesn't seem to be working... > > Thanks.