MathGroup Archive 2008

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

Search the Archive

Re: how to test where a list contains constant(s) or not

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92004] Re: how to test where a list contains constant(s) or not
  • From: dh <dh at metrohm.ch>
  • Date: Tue, 16 Sep 2008 19:26:03 -0400 (EDT)
  • References: <gal3iu$e0a$1@smc.vnet.net>


Hi Aya,

a complex number is numeric, therefore you only need to test for 

NumericQ. E.g.:

MemberQ[yourList, _?NumericQ]

However, there seems to be a problem with what you consider a constant. 

As Mathematica evaluates the arguments of functions, the following gives 

True:

a=1; MemberQ[{a}, _?NumericQ]

Is this what you want???

hope this helps, Daniel



Aya wrote:

> case1: { a, b, c, Pi }   gives true because of Pi

> case2: { a, b, c, 0.0001} gives true because of 0.0001

> case3: { a, b, c,  2 + Pi I } gives ture becase of 2 + Pi I

> case4: { a, b, c} gives false

> 

> is this function right ?

> 

> ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ],

> Complex] )

> IsConstantsIn[ lstList_ ] :=

> 		Module[ { intLength },

> 			intLength = Length@Select[ lstList, ComplexQ[ # ]& ];

> 			If[ intLength > 0, Return[ True ], Return[ False ] ];

> 			Return[ False ];

> 			]

> 





-- 



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>




  • Prev by Date: Re: Problem with replacement rules
  • Next by Date: Re: eliminate values while caculating Mean[data]
  • Previous by thread: Re: how to test where a list contains constant(s) or not
  • Next by thread: Re: how to test where a list contains constant(s) or not