Re: how to build pattern for a square matrix of reals?
- To: mathgroup at smc.vnet.net
- Subject: [mg98452] Re: how to build pattern for a square matrix of reals?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Fri, 10 Apr 2009 04:52:46 -0400 (EDT)
- References: <grhp95$mj7$1@smc.vnet.net> <grkgmm$6kq$1@smc.vnet.net>
sagrailo at gmail.com wrote:
> Sorry, I still have some related issues: if I have say two vectors
> (lists) as function arguments, how to build pattern that will verify
> that the length of the second vector is equal to the size of the first
> vector? Also, how to check that specific element of some vector have
> specific value? I tried something like:
> Foo[v1:{_Real..}/;Length[Dimensions[v1]]==1&&v1[[1]]==0,v2:
> {_Real..}/;Length[Dimensions[v2]]==1&&Dimensions[v2][[1]]==Dimensions
> [v1][[1]]]:="OK"
> but it doesn't work...
This is what I would do:
foo[v1_?(VectorQ[#, NumericQ] &), v2_?(VectorQ[#, NumericQ] &)] /;
And[v1[[1]] == 0, Length[v1] == Length[v2]] := "OK"
hth,
albert