Re: more with lists
- To: mathgroup at smc.vnet.net
- Subject: [mg40339] Re: [mg40326] more with lists
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 2 Apr 2003 04:35:25 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Let, for example, ls=Table[{Random[],Random[]},{10}] {{0.674904,0.947432},{0.712511,0.325852},{ 0.895512,0.674274},{0.472473,0.430607},{ 0.360706,0.529332},{ 0.42937,0.52123},{0.60123,0.619804},{0.415462,0.3121},{0.778426,0.738771 },\ {0.453092,0.290448}} One way: Cases[ls,{x_,y_}/;x<0.5&&y>0.4] {{0.472473,0.430607},{0.360706,0.529332},{0.42937,0.52123}} Another way: Select[ls,First[#]<0.5&&Last[#]>0.4&] {{0.472473,0.430607},{0.360706,0.529332},{0.42937,0.52123}} (There are also several other variations of these two basic methods.) Andrzej Kozlowski Yokohama, Japan http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/ On Tuesday, April 1, 2003, at 06:52 pm, Nathan Moore wrote: > The replies have been beautiful! > > suppose I have a list of n {x,y}pairs. I'd like to cull the list into > a > smaller list for which the condition x<Xo, y>Yo is true. If the list > was > 1-D I could simply use "Select," how do I access the data points in > pairs? > > Nathan Moore > Universoty of Minnesota Physics > > > >