Re: Select x s.t. y>10
- To: mathgroup at smc.vnet.net
- Subject: [mg14019] Re: [mg13957] Select x s.t. y>10
- From: "Jens-Peer Kuska" <kuska at linmpi.mpg.de>
- Date: Wed, 16 Sep 1998 14:12:00 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Hi, say Your data are named data than You can just write what you want First[Select[data,Last[#]>5 &]] If You don't like to waste time computing all elements larger than 5 You can write Catch[Scan[If[Last[#]>5,Throw[#],Null] &,data]] If You don't like Catch and Throw You can still use pattern matching with First[data /. {x_,y_?NumericQ} /; y<=5 :> Sequence[]] Hope that helps Jens -----Original Message----- From: Jason Gill <jgill at vbimail.champlain.edu> To: mathgroup at smc.vnet.net Subject: [mg14019] [mg13957] Select x s.t. y>10 >I came across what seems like it should be a simple little function, but >could not come up with a clever way to implement it. Generally, what I >am trying to do is take a list of lists of length 2 ie a list of x,y >coordinates, and Select x values based on some criterion for y. For >example I want to select the first x value for which the corresponding >y is greater than 5. >I can write a function using Position and Take etc. , but there must be >a clever,and more efficient way to do this. Any thoughts... Jason > >-- >Jason Gill >IBM Microelectronics >Essex Junction, VT 05452 >Phone (802)769-3350 >Fax (802)769-1220 >email: jgill at vbimail.champlain.edu > jasongil at us.ibm.com > > >