Re: Position
- To: mathgroup at smc.vnet.net
- Subject: [mg131131] Re: Position
- From: "Alexander Elkins" <alexander_elkins at hotmail.com>
- Date: Fri, 14 Jun 2013 04:56:15 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <kpbp24$95n$1@smc.vnet.net>
Use Condition(/;) on a Pattern named x matching any Real to test x for Greater than 2.0 like so: In[1]:= Position[{1.4,3.5,2.1,-1.2},x_Real/;x>2.] Out[1]= {{2},{3}} In[2]:= FullForm[x_Real /; x > 2.] Out[2]= Condition[Pattern[x, Blank[Real]], Greater[x, 2.`]] Or use PatternTest on an unnamed pattern matching any Real to test it for Greater than 2.0 like so: In[3]:= Position[{1.4,3.5,2.1,-1.2},_Real?(#>2.&)] Out[3]= {{2},{3}} In[4]:= FullForm[_Real?(#>2.&)] Out[4]//FullForm= PatternTest[Blank[Real],Function[Greater[Slot[1],2.`]]] "Costa Bravo" <q13a27tt at aol.com> wrote in message news:kpbp24$95n$1 at smc.vnet.net... > How can I find the indices of all elements greaters than e.g. 2 of a vector. > > t=RandomReal[{0,5},100] > Position[t,??] > > -- > Costa >